|
| 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 | +# |
| 26 | +# Binlog option for recovery run. This must be set in the test because |
| 27 | +# combinations file causes log-bin option to be set from command line, |
| 28 | +# not via my.cnf. |
| 29 | +# |
| 30 | +--let $log_bin = `SELECT @@log_bin` |
| 31 | +if ($log_bin) { |
| 32 | +--let $wsrep_recover_binlog_opt = --log-bin |
| 33 | +} |
| 34 | + |
| 35 | +# |
| 36 | +# Scenario 1 |
| 37 | +# The expected recovered seqno is 1 corresponding to initial cluster |
| 38 | +# configuration change. |
| 39 | +# |
| 40 | +--source include/kill_mysqld.inc |
| 41 | +--source wsrep-recover-step.inc |
| 42 | +--echo Expect seqno 0 |
| 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 1 corresponding to CREATE TABLE |
| 52 | +# |
| 53 | + |
| 54 | +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; |
| 55 | +--source include/kill_mysqld.inc |
| 56 | +--source wsrep-recover-step.inc |
| 57 | +--echo Expect seqno 1 |
| 58 | +--echo $wsrep_recover_start_position_seqno |
| 59 | + |
| 60 | +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno |
| 61 | +--source include/start_mysqld.inc |
| 62 | +--source include/wait_wsrep_ready.inc |
| 63 | + |
| 64 | +# |
| 65 | +# Scenario 3 |
| 66 | +# The expected recovered seqno is 2 corresponding to CREATE TABLE and INSERT. |
| 67 | +# |
| 68 | +# The expected wsrep_last_committed after the server is restarted is 2. |
| 69 | +# |
| 70 | + |
| 71 | +INSERT INTO t1 VALUES (5); |
| 72 | +--source include/kill_mysqld.inc |
| 73 | +--source wsrep-recover-step.inc |
| 74 | +--echo Expect seqno 2 |
| 75 | +--echo $wsrep_recover_start_position_seqno |
| 76 | +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno |
| 77 | +--source include/start_mysqld.inc |
| 78 | +--source include/wait_wsrep_ready.inc |
| 79 | + |
| 80 | +SELECT VARIABLE_VALUE `expect 2` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'; |
| 81 | + |
| 82 | +# |
| 83 | +# Scenario 4 |
| 84 | +# |
| 85 | +# The INSERT gets prepared but not committed. |
| 86 | +# |
| 87 | +# If binlog is off, the expected outcome is that the INSERT gets committed |
| 88 | +# since it is already committed in the cluster. If binlog is on, the INSERT |
| 89 | +# should be rolled back during recovery phase since it has not yet |
| 90 | +# been logged into binlog. |
| 91 | +# |
| 92 | +--connect con1, localhost, root |
| 93 | +SET DEBUG_SYNC = "ha_commit_trans_after_prepare SIGNAL after_prepare_reached WAIT_FOR continue"; |
| 94 | +--send INSERT INTO t1 VALUES (7) |
| 95 | + |
| 96 | +--connection default |
| 97 | +SET DEBUG_SYNC = "now WAIT_FOR after_prepare_reached"; |
| 98 | +--source include/kill_mysqld.inc |
| 99 | +--source wsrep-recover-step.inc |
| 100 | +if ($log_bin) { |
| 101 | + --echo Expect seqno 2 |
| 102 | +} |
| 103 | +if (!$log_bin) { |
| 104 | + --echo Expect seqno 3 |
| 105 | +} |
| 106 | +--echo $wsrep_recover_start_position_seqno |
| 107 | +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno |
| 108 | +--source include/start_mysqld.inc |
| 109 | +--source include/wait_wsrep_ready.inc |
| 110 | + |
| 111 | +if ($log_bin) { |
| 112 | + --echo Expect 5 |
| 113 | +} |
| 114 | +if (!$log_bin) { |
| 115 | + --echo Expect 5 7 |
| 116 | +} |
| 117 | +SELECT * FROM t1; |
| 118 | + |
| 119 | +DROP TABLE t1; |
0 commit comments