revision-id: 7cabdc461b24fdebe599799d7964efa4b53815e3 (mariadb-10.1.39-91-g7cabdc461b2) parent(s): bdc961acc7ae9d5a3661ac425e936cd03dc5ccbb author: Sachin committer: Sachin timestamp: 2019-07-15 14:04:22 +0530 message: MDEV-6860 Parallel async replication hangs on a Galera node Wait for previous commit beore preparing next transation for galera (TODO a better commit message) --- mysql-test/suite/galera/r/6860.result | 40 +++++++++++++++++ mysql-test/suite/galera/t/6860.cnf | 4 ++ mysql-test/suite/galera/t/6860.test | 81 +++++++++++++++++++++++++++++++++++ sql/rpl_parallel.cc | 2 +- 4 files changed, 126 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/galera/r/6860.result b/mysql-test/suite/galera/r/6860.result new file mode 100644 index 00000000000..5c9c2d9a3bb --- /dev/null +++ b/mysql-test/suite/galera/r/6860.result @@ -0,0 +1,40 @@ +include/start_slave.inc +CREATE TABLE t1 (f1 int, f2 int) ENGINE=innodb; +CREATE TABLE t2 (f1 int, f2 int) ENGINE=innodb; +SET SESSION debug_dbug="+d,binlog_force_commit_id"; +set global binlog_commit_wait_usec=1000; +set global binlog_commit_wait_count=2; +SELECT COUNT(*) FROM t1; +COUNT(*) +500 +include/save_master_gtid.inc +#NODE 2 +include/sync_with_master_gtid.inc +SELECT COUNT(*) FROM t1; +COUNT(*) +500 +include/stop_slave.inc +set global slave_parallel_mode=optimistic; +include/start_slave.inc +set global binlog_commit_wait_usec=100000; +set global binlog_commit_wait_count=0; +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +include/save_master_gtid.inc +#NODE 2 +include/sync_with_master_gtid.inc +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +#NODE 3 +SELECT COUNT(*) FROM t1; +COUNT(*) +1000 +DROP TABLE t1; +DROP TABLE t2; +include/save_master_gtid.inc +include/sync_with_master_gtid.inc +STOP SLAVE; +RESET SLAVE ALL; +set global slave_parallel_mode=conservative; diff --git a/mysql-test/suite/galera/t/6860.cnf b/mysql-test/suite/galera/t/6860.cnf new file mode 100644 index 00000000000..1bd1adc305a --- /dev/null +++ b/mysql-test/suite/galera/t/6860.cnf @@ -0,0 +1,4 @@ +!include ../galera_2nodes_as_slave.cnf + +[mysqld.2] +slave-parallel-threads=10 diff --git a/mysql-test/suite/galera/t/6860.test b/mysql-test/suite/galera/t/6860.test new file mode 100644 index 00000000000..21b5e4f0fbb --- /dev/null +++ b/mysql-test/suite/galera/t/6860.test @@ -0,0 +1,81 @@ +--source include/have_innodb.inc +--source include/have_debug.inc + +--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 +--source include/galera_cluster.inc + +--connection node_2 +--disable_query_log +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_1, MASTER_USE_GTID=slave_pos; +#--query_vertical SHOW SLAVE STATUS +--enable_query_log +--source include/start_slave.inc +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 + +--connection node_1 +CREATE TABLE t1 (f1 int, f2 int) ENGINE=innodb; +CREATE TABLE t2 (f1 int, f2 int) ENGINE=innodb; + +--let $inserts=500 +--let $count=0 +SET SESSION debug_dbug="+d,binlog_force_commit_id"; +set global binlog_commit_wait_usec=1000; +set global binlog_commit_wait_count=2; +--disable_query_log +while($count < $inserts) +{ + --eval SET @commit_id= 10000+$count; + --eval insert into t1 values ($count,1) + --eval insert into t2 values ($count,1) + --inc $count +} +--enable_query_log +SELECT COUNT(*) FROM t1; +--source include/save_master_gtid.inc + +--connection node_2 +--echo #NODE 2 +--source include/sync_with_master_gtid.inc +SELECT COUNT(*) FROM t1; +--source include/stop_slave.inc +set global slave_parallel_mode=optimistic; +--source include/start_slave.inc + +--connection node_1 +set global binlog_commit_wait_usec=100000; +set global binlog_commit_wait_count=0; +--disable_query_log +--let $count=0 +while($count < $inserts) +{ + --eval SET @commit_id= 10500 + $count; + --eval insert into t1 values (500 + $count,1) + --eval insert into t2 values (500 + $count,1) + --inc $count +} +--enable_query_log +SELECT COUNT(*) FROM t1; +--source include/save_master_gtid.inc + +--connection node_2 +--echo #NODE 2 +--source include/sync_with_master_gtid.inc +SELECT COUNT(*) FROM t1; + +--connection node_3 +--echo #NODE 3 +--let $wait_condition= SELECT COUNT(*)=1000 from t1; +--source include/wait_condition.inc +SELECT COUNT(*) FROM t1; + +--connection node_1 +DROP TABLE t1; +DROP TABLE t2; +--source include/save_master_gtid.inc + +--connection node_2 +--source include/sync_with_master_gtid.inc + +STOP SLAVE; +RESET SLAVE ALL; +set global slave_parallel_mode=conservative; diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 8fef2d66635..7d38c36b840 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -1181,7 +1181,7 @@ handle_rpl_parallel_thread(void *arg) before, then wait now for the prior transaction to complete its commit. */ - if (rgi->speculation == rpl_group_info::SPECULATE_WAIT && + if ((rgi->speculation == rpl_group_info::SPECULATE_WAIT || WSREP_ON) && (err= thd->wait_for_prior_commit())) { slave_output_error_info(rgi, thd);