-
Type:
Bug
-
Status: Done
-
Priority:
Medium
-
Resolution: Fixed
-
Affects Version/s: 5.6.40-26.25, 5.7.22-29.26
-
Fix Version/s: 5.7.24-31.33, 5.6.42-28.30
-
Component/s: None
-
Labels:None
Similar to https://jira.mariadb.org/browse/MDEV-8834 but test case from MariaDB is not working.
I've added:
static my_bool wsrep_read_only_option(THD *thd, TABLE_LIST *all_tables) { int opt_readonly_saved = opt_readonly; ulong flag_saved = (ulong)(thd->security_context()->master_access() & SUPER_ACL); opt_readonly = 0; DEBUG_SYNC(thd, "read_only_cleared"); // added for test
and test case:
--source include/galera_cluster.inc --source include/have_innodb.inc CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; --connection node_2 SET GLOBAL read_only=TRUE; CREATE USER foo@localhost; SET DEBUG_SYNC= 'read_only_cleared SIGNAL not_ro WAIT_FOR ro_checked'; send INSERT INTO t1 VALUES (1); --echo # Open connection to node 2 using 'foo' user. --let $port_2= \$NODE_MYPORT_2 --connect(foo_node_2,127.0.0.1,foo,,test,$port_2,) --connection node_1 --echo --echo # Connect with foo_node_2 --connection foo_node_2 --error ER_OPTION_PREVENTS_STATEMENT INSERT INTO t1 VALUES (2);
Test fault output:
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009 galera.galera_read_only [ fail ] Test ended at 2018-09-14 16:16:38 CURRENT_TEST: galera.galera_read_only mysqltest: At line 32: query 'INSERT INTO t1 VALUES (2)' succeeded - should have failed with errno 1290... The result from queries just before the failure was: CREATE TABLE t1 (id INT PRIMARY KEY) ENGINE=InnoDB; SET GLOBAL read_only=TRUE; CREATE USER foo@localhost; SET DEBUG_SYNC= 'read_only_cleared SIGNAL not_ro WAIT_FOR ro_checked'; INSERT INTO t1 VALUES (1); # Open connection to node 2 using 'foo' user. # Connect with foo_node_2 safe_process[406]: Child process: 408, exit: 1
Race condition happens between:
https://github.com/percona/percona-xtradb-cluster/blob/5.7/sql/sql_parse.cc#L1285
and https://github.com/percona/percona-xtradb-cluster/blob/5.7/sql/auth/sql_authorization.cc#L503
Both should be called on the same PXC node, because wsrep_read_only_option is not called if row replicated from other host.