|
| 1 | +# |
| 2 | +# Test Galera as a slave to a MariaDB master using sequence table and GTID mode |
| 3 | +# |
| 4 | +# In the problematic execution scenario, seqence access marks GTID event as DDL |
| 5 | +# and applier makes implicit commit before the actual transaction is even applied. |
| 6 | +# Second commit attempt after the actual payload applying would then wait for |
| 7 | +# commit order eternally, causing total cluster hang |
| 8 | +# |
| 9 | +# |
| 10 | + |
| 11 | +--source include/have_innodb.inc |
| 12 | +--source include/have_log_bin.inc |
| 13 | +--source include/galera_cluster.inc |
| 14 | + |
| 15 | +# |
| 16 | +# node_1 = galera cluster replica node |
| 17 | +# node_2 = galera cluster node, operating as replication slave for node_3 |
| 18 | +# node_3 = regular mariadb server operating as replication master |
| 19 | +# |
| 20 | + |
| 21 | +# enable parallel applying in galera cluster replica node |
| 22 | +--connection node_1 |
| 23 | +SET global wsrep_slave_threads = 2; |
| 24 | + |
| 25 | +# As node #3 is not a Galera node, and galera_cluster.inc does not open connetion to it |
| 26 | +# we open the node_3 connection here |
| 27 | +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 |
| 28 | + |
| 29 | +--connection node_2 |
| 30 | +--disable_query_log |
| 31 | +--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_PORT=$NODE_MYPORT_3; |
| 32 | +--enable_query_log |
| 33 | +START SLAVE; |
| 34 | + |
| 35 | +--connection node_3 |
| 36 | +CREATE SEQUENCE my_seq INCREMENT BY 1 NOCACHE ENGINE=INNODB; |
| 37 | +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
| 38 | +insert into t1 values (0); |
| 39 | + |
| 40 | +BEGIN; |
| 41 | +# spend some sequence values |
| 42 | +select nextval(my_seq); |
| 43 | +select nextval(my_seq); |
| 44 | +select nextval(my_seq); |
| 45 | + |
| 46 | +# regular insert, which may cause duplicate commit in node_1 |
| 47 | +insert into t1 values (1); |
| 48 | +COMMIT; |
| 49 | + |
| 50 | +# feed some more DML, which may cause hang in galera replication, node_1 |
| 51 | +insert into t1 values (2); |
| 52 | +delete from t1; |
| 53 | + |
| 54 | +# |
| 55 | +# Scenario where seqeunce value is used in a SQL statement |
| 56 | +# |
| 57 | +DROP TABLE t1; |
| 58 | +CREATE TABLE t1(a int not null primary key default nextval(my_seq), b int) engine=innodb; |
| 59 | + |
| 60 | +BEGIN; |
| 61 | +INSERT INTO t1(b) VALUES(3); |
| 62 | +INSERT INTO t1(a,b) VALUES(10,4); |
| 63 | +COMMIT; |
| 64 | + |
| 65 | +delete from t1; |
| 66 | + |
| 67 | +# tear down the replication, force galera nodes to apply all remaining as single threaded |
| 68 | +--connection node_1 |
| 69 | +SET global wsrep_slave_threads = DEFAULT; |
| 70 | + |
| 71 | +--connection node_3 |
| 72 | +DROP SEQUENCE my_seq; |
| 73 | +DROP TABLE t1; |
| 74 | + |
| 75 | +# wait untill replication channel is flushed and all is applied in node_1 |
| 76 | +--connection node_1 |
| 77 | +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1' |
| 78 | +--source include/wait_condition.inc |
| 79 | +--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'my_seq' |
| 80 | +--source include/wait_condition.inc |
| 81 | + |
| 82 | +--connection node_2 |
| 83 | +STOP SLAVE; |
| 84 | +RESET SLAVE ALL; |
| 85 | + |
| 86 | +--connection node_1 |
| 87 | +set global wsrep_on=OFF; |
| 88 | +reset master; |
| 89 | +set global wsrep_on=ON; |
| 90 | + |
| 91 | +--connection node_2 |
| 92 | +set global wsrep_on=OFF; |
| 93 | +reset master; |
| 94 | +set global wsrep_on=ON; |
| 95 | + |
| 96 | +--connection node_3 |
| 97 | +reset master; |
0 commit comments