Debian Codegraph @

mysql-test/suite/wsrep/t/wsrep-recover.test

raw
1 #
2 # Verify that the wsrep XID gets updated in InnoDB rollback segment
3 # properly and can be recovered with --wsrep-recover
4 #
5 # The test runs the following scenarios:
6 #
7 # 1) The server is started but no SQL is run
8 # 2) DDL is executed
9 # 3) INSERT is executed
10 # 4) Two INSERTs are executed so that the first one in order will be
11 # blocked after certification and the second one before entering
12 # commit order critical section.
13 # 5) Two DMLs are executed so that the prepare step is run out of order.
14 # Both transactions are blocked before commit order critical section.
15 #
16 # After each scenario server is killed and the recovered position
17 # is validated.
18 #
19
20 --source include/have_wsrep.inc
21 --source include/have_innodb.inc
22 --source include/have_wsrep_provider.inc
23 --source include/have_debug_sync.inc
24
25 # Binlog option for recovery run. This must be set in the test because
26 # combinations file causes log-bin option to be set from command line,
27 # not via my.cnf.
28 #
29 --let $log_bin = `SELECT @@log_bin`
30 if ($log_bin) {
31 --let $wsrep_recover_binlog_opt = --log-bin
32 }
33
34 #
35 # Scenario 1
36 # The expected recovered seqno is 1 corresponding to initial cluster
37 # configuration change.
38 #
39 let $restart_noprint=2;
40 --source include/kill_mysqld.inc
41 --source wsrep-recover-step.inc
42 --echo Expect seqno 1
43 --echo $wsrep_recover_start_position_seqno
44
45 --let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno
46 --source include/start_mysqld.inc
47 --source include/wait_wsrep_ready.inc
48
49 #
50 # Senario 2
51 # The expected recovered seqno is 3 corresponding to two configuration
52 # change events and CREATE TABLE.
53 #
54 let $restart_noprint=2;
55
56 CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB;
57 --source include/kill_mysqld.inc
58 --source wsrep-recover-step.inc
59 --echo Expect seqno 3
60 --echo $wsrep_recover_start_position_seqno
61
62 --let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno
63 --source include/start_mysqld.inc
64 --source include/wait_wsrep_ready.inc
65
66 #
67 # Scenario 3
68 # The expected recovered seqno is 5 corresponding to three configuration
69 # change events, CREATE TABLE and INSERT.
70 #
71 # The expected wsrep_last_committed after the server is restarted is 6.
72 #
73 let $restart_noprint=2;
74
75 INSERT INTO t1 VALUES (5);
76 --source include/kill_mysqld.inc
77 --source wsrep-recover-step.inc
78 --echo Expect seqno 5
79 --echo $wsrep_recover_start_position_seqno
80 --let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno
81 --source include/start_mysqld.inc
82 --source include/wait_wsrep_ready.inc
83
84 SELECT VARIABLE_VALUE `expect 6` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed';
85
86 #
87 # Scenario 4
88 #
89 # This will cause the following
90 #
91 # Seqno 7 - the first INSERT is blocked after it is certified but before
92 # it gets prepared
93 # Seqno 8 - the second INSERT is blocked before it will be ordered for
94 # commit, so it becomes prepared
95 #
96 # As an outcome, the recovery process should return seqno 6 because
97 # the range of prepared transactions found after the crash recovery
98 # is not continuous up to 8.
99 #
100 # The expected wsrep_last_committed after server is restarted is 7.
101 #
102
103 # Send INSERT which will block after certification
104 --connect con1, localhost, root
105 SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue";
106 --send INSERT INTO t1 VALUES (7)
107
108 --connect con_ctrl, localhost, root
109 SET DEBUG_SYNC = "now WAIT_FOR after_certification_reached";
110
111 # Send INSERT which will block before commit order critical section
112 --connect con2, localhost, root
113 SET DEBUG_SYNC = "wsrep_before_commit_order_enter SIGNAL before_commit_order_reached WAIT_FOR continue";
114 --send INSERT INTO t1 VALUES (8)
115
116 --connection con_ctrl
117 SET DEBUG_SYNC = "now WAIT_FOR before_commit_order_reached";
118
119 --connection default
120 let $restart_noprint=2;
121 --source include/kill_mysqld.inc
122 --source wsrep-recover-step.inc
123 --echo Expect seqno 6
124 --echo $wsrep_recover_start_position_seqno
125 --let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno
126 --source include/start_mysqld.inc
127 --source include/wait_wsrep_ready.inc
128
129 --disconnect con1
130 --disconnect con2
131 --disconnect con_ctrl
132 --connection default
133
134 SELECT VARIABLE_VALUE `expect 7` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed';
135
136 #
137 # Scenario 5
138 #
139 # This scenario will run two INSERTs in parallel so that they are
140 # prepared out of order. The execution is stopped before commit
141 # and the server is killed.
142 #
143 # The transactions will be recovered from InnoDB but
144 # will be rolled back:
145 # - If binlog is on, the binlog acts as a transaction coordinator.
146 # The transaction is not logged into binlog, so the transaction is rolled
147 # back.
148 # - If binlog is not on, the transaction is 1PC and the wsrep XID
149 # is not persisted before commit is complete.
150 #
151
152 --connect con1, localhost, root
153 SET DEBUG_SYNC = "wsrep_after_certification SIGNAL after_certification_reached WAIT_FOR continue_after_certification";
154 SET DEBUG_SYNC = "wsrep_before_commit_order_enter SIGNAL before_commit_order_reached_1 WAIT_FOR continue_before_commit_order_1";
155 --send INSERT INTO t1 VALUES (9)
156
157 --connect con_ctrl, localhost, root
158 SET DEBUG_SYNC = "now WAIT_FOR after_certification_reached";
159
160 --connect con2, localhost, root
161 SET DEBUG_SYNC = "wsrep_before_commit_order_enter SIGNAL before_commit_order_reached_2 WAIT_FOR continue_before_commit_order_2";
162 --send INSERT INTO t1 VALUES (10)
163
164 --connection con_ctrl
165 SET DEBUG_SYNC = "now WAIT_FOR before_commit_order_reached_2";
166 SET DEBUG_SYNC = "now SIGNAL continue_after_certification";
167 SET DEBUG_SYNC = "now WAIT_FOR before_commit_order_reached_1";
168
169 --connection default
170 let $restart_noprint=2;
171 --source include/kill_mysqld.inc
172 --source wsrep-recover-step.inc
173 --echo Expect seqno 7
174
175 --echo $wsrep_recover_start_position_seqno
176 --let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno
177 --source include/start_mysqld.inc
178 --source include/wait_wsrep_ready.inc
179
180 --disconnect con1
181 --disconnect con2
182 --disconnect con_ctrl
183 --connection default
184
185
186 SELECT VARIABLE_VALUE `expect 8` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed';
187
188 #
189 # Final sanity check: The successful inserts into t1 should result single row
190 #
191 --echo Expect row 5
192 SELECT * FROM t1;
193
194 DROP TABLE t1;