Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_rotate_gtid.test

raw
1 # ==== Purpose ====
2 #
3 # When the slave SQL thread processes transactions, it internally keeps
4 # track of the starting position of the current transaction. This position
5 # is used to rewind the position in case the SQL thread is stopped in the
6 # middle of a transaction, or in case the transaction is re-executed due to
7 # replica_transaction_retries > 0.
8 #
9 # This test verifies that the start of the transaction is correctly updated
10 # even if the transaction spans multiple relay logs, such that a Gtid_log_event
11 # is immediately followed by a Rotate_log_event.
12 #
13 # ==== Related Bugs and Worklogs ====
14 #
15 # Bug #18652178 STOP SQL_THREAD, START SQL_THREAD
16 # CAUSES A TRX TO LOG WITH A DIFFERENT GTID
17 #
18 --source include/have_binlog_format_statement.inc
19 --source include/master-slave.inc
20 # Test should run only on debug build
21 source include/have_debug.inc;
22 source include/have_debug_sync.inc;
23
24
25 --echo # Preparing the relaylog
26 #
27 # Create a relaylog on slave containing a relaylog file that finishes with
28 # an Gtig_log_event and the rest of the group (transaction) is in the
29 # next relaylog file.
30 #
31 # The better way of doing this is disabling slave's auto positioning
32 # and using a debug point to stop the IO thread right after queuing
33 # the Gtid_log_event. Because auto positioning is disabled, the IO thread
34 # will not ask the Gtid_log_event again.
35 #
36 --source include/rpl_connection_slave.inc
37 --source include/stop_slave.inc
38 # Disabling auto positioning
39 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION=0;
40 # Make sync includes to rely on position instead of GTIDs
41 --let $use_gtids= 0
42 --source include/start_slave_io.inc
43
44 # Setting the debug point to stop IO thread after queuing Gtid_log_event
45 SET @save_debug=@@global.debug;
46 SET GLOBAL DEBUG='+d,stop_io_after_reading_gtid_log_event';
47
48 --echo # Create a transaction on the master
49 --echo # that will have it's GTID and other events in separated relay log files
50 --source include/rpl_connection_master.inc
51 CREATE TABLE t1 (c1 INT) ENGINE=InnoDB;
52
53 # Wait for IO thread to stop and restarts it to get the rest of the transaction
54 --source include/rpl_connection_slave.inc
55 --source include/wait_for_slave_io_to_stop.inc
56 SET GLOBAL DEBUG=@save_debug;
57 --source include/start_slave_io.inc
58
59 --echo # Create other transaction on the master
60 --source include/rpl_connection_master.inc
61 CREATE TABLE t2 (c1 INT) ENGINE=InnoDB;
62
63 --source include/sync_slave_io_with_master.inc
64
65 --echo # Restart the SQL thread until the beginning of the last relay log file
66 --source include/rpl_connection_slave.inc
67 # Disable warnings to avoid logging "UNTIL condtion is not supported ..." on MTS
68 --disable_warnings
69 START SLAVE SQL_THREAD UNTIL
70 RELAY_LOG_FILE= 'slave-relay-bin.000003',
71 RELAY_LOG_POS= 4;
72 --enable_warnings
73 --source include/wait_for_slave_sql_to_stop.inc
74
75 --echo # Restart the SQL thread
76 --source include/start_slave_sql.inc
77
78 --source include/rpl_connection_master.inc
79 --source include/sync_slave_sql_with_master.inc
80 # If t1 was replicated to the slave and it's original GTID was skipped
81 # this test will fail in the rpl_end.inc because the GTID_EXECUTED of the
82 # master contains a GTID that was sent to the slave (it is in
83 # Retrieved_Gtid_Set), but wasn't applied by the SQL thread.
84 --let $assert_cond= "[SHOW TABLES LIKE "t1"]" = "t1"
85 --let $assert_text= t1 should be replicated
86 --source include/assert.inc
87
88 --echo # Cleanup
89 --source include/rpl_connection_master.inc
90 DROP TABLE t1, t2;
91 # Make rpl_end.inc to verify GTID_EXECUTED
92 --let $use_gtids= 1
93 --source include/rpl_end.inc