Debian Codegraph @

mysql-test/suite/rpl_nogtid/t/rpl_sql_thread_killed_waiting_commit_lock.test

raw
1 # ==== Purpose ====
2 #
3 # Test if sql thread doesn't assert when it is killed at
4 # 'Waiting for commit lock' state.
5 #
6 # Test if killing sql thread which is waiting for commit lock and restarting
7 # it doesn't cause a transaction to be skipped on slave.
8 #
9 # ==== Related Bugs and Worklogs ====
10 #
11 # BUG#16861624: KILLING WAITING SLAVE SQL THREAD:
12 # M_STATUS == DA_ERROR || M_STATUS == DA_OK
13 #
14 # ==== Implementation ====
15 #
16 # In order to get the sql thread in the 'Waiting for commit lock' state
17 # we have to put some data into the master and, then, while replication
18 # is happening, lock the slave with 'FLUSH TABLES WITH READ LOCK'.
19 #
20 # Debug sync points were created to allow us to precisely put the
21 # sql thread in the desired state.
22 #
23 # After having the sql thread waiting for the commit lock, the test kills
24 # it identifying its ID by querying information_schema.processlist table.
25 #
26 # Bug#17450876: REPLICATION STOP WITH "ERROR IN XID_LOG_EVENT: COMMIT COULD
27 # NOT BE COMPLETED"
28 #
29 # Killing the sql thread that is waiting for a commit lock and restarting it
30 # will cause one transaction to be skipped on the slave. When sql thread is
31 # killed at this state its positions are updated in rli object but the
32 # transaction is yet to be committed. At the time of restart the rli object is
33 # read back causing a transaction to be missed. Post fix the positions in rli
34 # object will be rolled back. Test script ensures that rli's memory contents
35 # are in sync with the positions in rli repository.
36
37 --source include/have_binlog_format_mixed.inc
38 --source include/master-slave.inc
39 --source include/have_debug.inc
40 --source include/have_debug_sync.inc
41
42 call mtr.add_suppression("Query execution was interrupted.");
43 call mtr.add_suppression("The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state");
44
45 --echo # Let master and slave synced with t1 table created
46 CREATE TABLE t1 (f INT) ENGINE= INNODB;
47 --source include/sync_slave_sql_with_master.inc
48
49 --echo # Setup GLOBAL.DEBUG at slave to reach commit
50 --source include/rpl_connection_slave.inc
51 --let $debug_saved= `SELECT @@GLOBAL.DEBUG`
52 SET @@GLOBAL.DEBUG= '+d,dbug.reached_commit';
53
54 --echo # Do some DML operation on master so that it will be blocked on
55 --echo # slave as global read lock is in place.
56 --source include/rpl_connection_master.inc
57 INSERT INTO t1 VALUES (10);
58
59 --echo # Issue FLUSH TABLES WITH READ LOCK after Reached is signaled
60 --source include/rpl_connection_slave.inc
61 SET DEBUG_SYNC='now WAIT_FOR Reached';
62 FLUSH TABLES WITH READ LOCK;
63 --echo # Let sql thread continue to try to obtain commit lock
64 SET DEBUG_SYNC= 'now SIGNAL signal.commit_continue';
65
66 --echo # Wait until sql thread enters "Waiting for commit lock" state
67 let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist
68 WHERE state = "Waiting for commit lock";
69 --source include/wait_condition.inc
70
71 --echo # Kill sql thread
72 let $sql_thread_id= `SELECT ID FROM information_schema.processlist
73 WHERE state= "Waiting for commit lock"`;
74 --disable_query_log
75 --eval KILL $sql_thread_id
76 --enable_query_log
77 --let $slave_sql_errno= convert_error(ER_QUERY_INTERRUPTED)
78 --source include/wait_for_slave_sql_error.inc
79
80 --echo # Restart sql thread to let it finish the replication
81 SET @@GLOBAL.DEBUG= '-d,dbug.reached_commit';
82 UNLOCK TABLES;
83 # Check to ensure that in memory rli positions are equal to the positions in
84 # slave's repository table.
85 if (`SELECT @@GLOBAL.relay_log_info_repository = 'TABLE'`)
86 {
87 --let $slave_master_log_pos_in_repo= `SELECT Master_log_pos FROM mysql.slave_relay_log_info LIMIT 1`
88 }
89 if (`SELECT @@GLOBAL.relay_log_info_repository = 'FILE'`)
90 {
91 --disable_query_log
92 CREATE TABLE rli_table(rli_info VARCHAR(100));
93 --let $MYSQLD_DATADIR= `select @@datadir`
94 --let $rli_file=$MYSQLD_DATADIR/relay-log.info
95 --replace_result $rli_file rli_file
96 --eval LOAD DATA LOCAL INFILE '$rli_file' INTO TABLE rli_table
97 --let $slave_master_log_pos_in_repo= `SELECT * FROM rli_table LIMIT 4,1`
98 DROP TABLE rli_table;
99 --enable_query_log
100 }
101
102 --let $slave_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
103 --let $assert_text= Exec_Master_Log_Pos in SHOW SLAVE STATUS must be equal to mater_log_pos in slave's repository
104 --let $assert_cond= $slave_master_log_pos = $slave_master_log_pos_in_repo
105 --source include/assert.inc
106 --source include/start_slave_sql.inc
107
108 # Check consistency
109 --source include/rpl_connection_master.inc
110 --source include/sync_slave_sql_with_master.inc
111 --let $diff_tables= master:t1, slave:t1
112 --source include/diff_tables.inc
113
114 # Cleanup
115 --source include/rpl_connection_master.inc
116 DROP TABLE t1;
117 --source include/rpl_end.inc