Skip to content

Commit ce28fa5

Browse files
committed
Backported wsrep-recover test from 10.4.
Backported wsrep-recover test from 10.4 to test the wsrep recovery after database shutdown or crash. Renamed the test to wsrep-recover-v25 to avoid conflicts with existing test in 10.4 and to provide coverage for wsrep-API v25 compatible behavior. The test case in 10.2 is simpler because out of order prepare step cannot happen, the commit order critical section is grabbed before prepare phase. Test is not recorded since it does not produce expected result.
1 parent fab531a commit ce28fa5

File tree

4 files changed

+171
-0
lines changed

4 files changed

+171
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#
2+
# Macro to run wsrep recovery step. This is adapted from
3+
# suite/galera/include/galera_wsrep_recover.inc, with additional
4+
# option to pass binlog argument to recovery command. The macro
5+
# returns recovered position split in uuid and seqno parts.
6+
#
7+
# Arguments:
8+
#
9+
# wsrep_recover_binlog_opt - Binlog options to recovery command
10+
#
11+
# Return:
12+
#
13+
# wsrep_recover_start_position_uuid - UUID corresponding to recovered position
14+
# wsrep_recover_start_position_seqno - seqno corresponding to recovered position
15+
#
16+
17+
--exec $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.log --innodb --wsrep-recover $wsrep_recover_binlog_opt --core-file > $MYSQL_TMP_DIR/galera_wsrep_recover.log 2>&1
18+
19+
--perl
20+
use strict;
21+
my $wsrep_start_position = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`;
22+
chomp($wsrep_start_position);
23+
die if $wsrep_start_position eq '';
24+
open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/galera_wsrep_start_position.inc") or die;
25+
my ($uuid, $seqno) = split /:/, $wsrep_start_position;
26+
print FILE "--let \$wsrep_recover_start_position_uuid = $uuid\n";
27+
print FILE "--let \$wsrep_recover_start_position_seqno = $seqno\n";
28+
close FILE;
29+
EOF
30+
31+
--source $MYSQL_TMP_DIR/galera_wsrep_start_position.inc
32+
33+
if ($wsrep_recover_start_position_uuid == '') {
34+
--die "Could not obtain start_position_uuid."
35+
}
36+
37+
if ($wsrep_recover_start_position_seqno == '') {
38+
--die "Could not obtain start_position_seqno."
39+
}
40+
41+
--remove_file $MYSQL_TMP_DIR/galera_wsrep_start_position.inc
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
!include ../my.cnf
2+
3+
[mysqld.1]
4+
wsrep-on=ON
5+
wsrep-cluster-address=gcomm://
6+
wsrep-provider=@ENV.WSREP_PROVIDER
7+
binlog-format=ROW
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[binlogon]
2+
log-bin
3+
4+
[binlogoff]
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
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

Comments
 (0)