Debian Codegraph @

mysql-test/suite/rpl/t/rpl_non_atomic_ddl.test

raw
1 # ==== Purpose ====
2 #
3 # The test verifies the slave applier recovery after non-atomic DDL
4 # crashes the server.
5 # The test specifies slave_relay_log_info as of TABLE type.
6 # At post-crash the slave service must recover and the applier resumes
7 # from a correct binlog position.
8 # The subject is not trivial as it may look because even with the slave binlogging
9 # turned ON the post-crash recovering slave can't make use of its binlog as
10 # the non-atomic DDL is not xided.
11 #
12 # ==== Implementation ====
13 #
14 # Simulate the crash once a non-atomic DDL completes on the slave
15 # server including the final phase of the slave applier committing an
16 # update into the info table.
17 # At restart the slave server recovery must always find the slave info table updated
18 # so never attempt binlog-based recovery for it which otherwise would
19 # be in vain thanks to missed XID info.
20 #
21 # ==== References ====
22 # WL#9175 Correct recovery of DDL statements/transactions by binary log
23 #
24 # See other tests like rpl_atomic_ddl, rpl_half_atomic_ddl verifying
25 # the atomic DDL classes.
26 #
27
28 --source include/force_myisam_default.inc
29 --source include/have_myisam.inc
30 --source include/not_crashrep.inc
31 --source include/not_valgrind.inc
32 --source include/have_log_bin.inc
33 --source include/have_binlog_format_mixed.inc
34 --source include/have_debug.inc
35 --let $rpl_gtid_utils= 1
36 --source include/master-slave.inc
37
38 ##
39 ## Initialization
40 ##
41 --source include/rpl_connection_slave.inc
42 call mtr.add_suppression("The replica coordinator and worker threads are stopped");
43 call mtr.add_suppression("Replica worker thread has failed to apply an event");
44 call mtr.add_suppression("Error writing relay log configuration");
45
46 --source include/rpl_connection_master.inc
47 # instructing gtid_step_assert that is called by a sourced file
48 # to satisfy to gtid-mode OFF as well.
49 --let $gtid_mode_on= `SELECT @@GLOBAL.GTID_MODE = 'ON'`
50 --let $gtid_mode= `SELECT @@GLOBAL.GTID_MODE`
51 --let $gtid_step_gtid_mode_agnostic=`SELECT '$gtid_mode' != 'ON'`
52
53 # Leave slave applier stopped
54 --source include/sync_slave_sql_with_master.inc
55 --source include/stop_slave_sql.inc
56
57 if (!$crash_commit)
58 {
59 --let $commit_message=Crash right after the non-atomic DDL's event has updated slave relay log info
60 --let $crash_commit="+d,replica_crash_after_commit_no_atomic_ddl"
61 }
62
63 ##
64 ## Execution
65 ##
66
67 --let $table_name=tm
68 --let $current_query=CREATE TABLE $table_name (a int) ENGINE=MYISAM
69
70 --source include/rpl_connection_master.inc
71 --eval $current_query
72 --let $binlog_pos= query_get_value("SHOW MASTER STATUS", Position, 1)
73
74 --source include/sync_slave_io_with_master.inc
75
76 # The receiver thread must be stopped now which
77 # crash-safely memorizes the last received event coordinates.
78 --source include/rpl_connection_slave.inc
79 --source include/stop_slave_io.inc
80
81 # Set up post-commit crash
82 --source include/expect_crash.inc
83 --echo *** Query: '$current_query'. $commit_message. ***
84 --eval SET @@GLOBAL.debug=$crash_commit
85
86 --error 0,2013
87 START SLAVE SQL_THREAD;
88
89 # Server wait for stop and restart
90 --enable_reconnect
91 --source include/wait_until_disconnected.inc
92 --let $rpl_server_number= 2
93 --source include/rpl_start_server.inc
94 --disable_reconnect
95
96 --source include/rpl_connection_slave.inc
97 --let $assert_text=The table $table_name must be present
98 --let $assert_cond=`SELECT count(*) = 0 FROM $table_name`
99 --source include/assert.inc
100
101 # The last executed position post crash recovery is extraneous.
102 # Eventual 'START SLAVE' must succeed and would not when the last execution
103 # coordiate remained as before the crash as the table could not be
104 # re-CREATE-ed.
105 --let $assert_text=The executed coordinates must be as after the crashing '$current_query'
106 if (`select @@global.replica_parallel_workers = 0`)
107 {
108 --let $assert_cond=`SELECT Master_log_pos = $binlog_pos FROM mysql.slave_relay_log_info`
109 }
110 if (`select @@global.replica_parallel_workers > 0`)
111 {
112 --let $assert_cond=`SELECT max(Master_log_pos) = $binlog_pos FROM mysql.slave_worker_info`
113 }
114 --source include/assert.inc
115
116 --source include/start_slave.inc
117
118 --source include/rpl_connection_master.inc
119 --eval DROP TABLE $table_name
120
121 --source include/sync_slave_sql_with_master.inc
122
123 --source include/rpl_end.inc