diff options
author | Teemu Ollakka <teemu.ollakka@galeracluster.com> | 2019-01-24 16:01:28 +0200 |
---|---|---|
committer | Teemu Ollakka <teemu.ollakka@galeracluster.com> | 2019-01-25 16:03:14 +0200 |
commit | ce28fa53032dd7c233ed4875514bf85eafec0bc4 (patch) | |
tree | b5cb3b6df1fdfdf58cc524de6c62452128bdcf97 /mysql-test | |
parent | fab531a150ec588f87e8a636d2ba1ecbfffdb08e (diff) | |
download | mariadb-git-ce28fa53032dd7c233ed4875514bf85eafec0bc4.tar.gz |
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.
Diffstat (limited to 'mysql-test')
-rw-r--r-- | mysql-test/suite/wsrep/t/wsrep-recover-step.inc | 41 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf | 7 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations | 4 | ||||
-rw-r--r-- | mysql-test/suite/wsrep/t/wsrep-recover-v25.test | 119 |
4 files changed, 171 insertions, 0 deletions
diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-step.inc b/mysql-test/suite/wsrep/t/wsrep-recover-step.inc new file mode 100644 index 00000000000..22669438fe0 --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-step.inc @@ -0,0 +1,41 @@ +# +# Macro to run wsrep recovery step. This is adapted from +# suite/galera/include/galera_wsrep_recover.inc, with additional +# option to pass binlog argument to recovery command. The macro +# returns recovered position split in uuid and seqno parts. +# +# Arguments: +# +# wsrep_recover_binlog_opt - Binlog options to recovery command +# +# Return: +# +# wsrep_recover_start_position_uuid - UUID corresponding to recovered position +# wsrep_recover_start_position_seqno - seqno corresponding to recovered position +# + +--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 + +--perl + use strict; + my $wsrep_start_position = `grep 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; + chomp($wsrep_start_position); + die if $wsrep_start_position eq ''; + open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/galera_wsrep_start_position.inc") or die; + my ($uuid, $seqno) = split /:/, $wsrep_start_position; + print FILE "--let \$wsrep_recover_start_position_uuid = $uuid\n"; + print FILE "--let \$wsrep_recover_start_position_seqno = $seqno\n"; + close FILE; +EOF + +--source $MYSQL_TMP_DIR/galera_wsrep_start_position.inc + +if ($wsrep_recover_start_position_uuid == '') { + --die "Could not obtain start_position_uuid." +} + +if ($wsrep_recover_start_position_seqno == '') { + --die "Could not obtain start_position_seqno." +} + +--remove_file $MYSQL_TMP_DIR/galera_wsrep_start_position.inc diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf b/mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf new file mode 100644 index 00000000000..b1c96d2614d --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-v25.cnf @@ -0,0 +1,7 @@ +!include ../my.cnf + +[mysqld.1] +wsrep-on=ON +wsrep-cluster-address=gcomm:// +wsrep-provider=@ENV.WSREP_PROVIDER +binlog-format=ROW diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations b/mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations new file mode 100644 index 00000000000..1ce3b45aa1a --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-v25.combinations @@ -0,0 +1,4 @@ +[binlogon] +log-bin + +[binlogoff] diff --git a/mysql-test/suite/wsrep/t/wsrep-recover-v25.test b/mysql-test/suite/wsrep/t/wsrep-recover-v25.test new file mode 100644 index 00000000000..cfd77fbdef4 --- /dev/null +++ b/mysql-test/suite/wsrep/t/wsrep-recover-v25.test @@ -0,0 +1,119 @@ +# +# Verify that the wsrep XID gets updated in InnoDB rollback segment +# properly and can be recovered with --wsrep-recover +# +# The test runs the following scenarios: +# +# 1) The server is started but no SQL is run +# 2) DDL is executed +# 3) INSERT is executed +# 4) Two INSERTs are executed so that the first one in order will be +# blocked after certification and the second one before entering +# commit order critical section. +# 5) Two DMLs are executed so that the prepare step is run out of order. +# Both transactions are blocked before commit order critical section. +# +# After each scenario server is killed and the recovered position +# is validated. +# + +--source include/have_wsrep.inc +--source include/have_innodb.inc +--source include/have_wsrep_provider.inc +--source include/have_debug_sync.inc + +# +# Binlog option for recovery run. This must be set in the test because +# combinations file causes log-bin option to be set from command line, +# not via my.cnf. +# +--let $log_bin = `SELECT @@log_bin` +if ($log_bin) { +--let $wsrep_recover_binlog_opt = --log-bin +} + +# +# Scenario 1 +# The expected recovered seqno is 1 corresponding to initial cluster +# configuration change. +# +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +--echo Expect seqno 0 +--echo $wsrep_recover_start_position_seqno + +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +# +# Senario 2 +# The expected recovered seqno is 1 corresponding to CREATE TABLE +# + +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +--echo Expect seqno 1 +--echo $wsrep_recover_start_position_seqno + +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +# +# Scenario 3 +# The expected recovered seqno is 2 corresponding to CREATE TABLE and INSERT. +# +# The expected wsrep_last_committed after the server is restarted is 2. +# + +INSERT INTO t1 VALUES (5); +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +--echo Expect seqno 2 +--echo $wsrep_recover_start_position_seqno +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +SELECT VARIABLE_VALUE `expect 2` FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_last_committed'; + +# +# Scenario 4 +# +# The INSERT gets prepared but not committed. +# +# If binlog is off, the expected outcome is that the INSERT gets committed +# since it is already committed in the cluster. If binlog is on, the INSERT +# should be rolled back during recovery phase since it has not yet +# been logged into binlog. +# +--connect con1, localhost, root +SET DEBUG_SYNC = "ha_commit_trans_after_prepare SIGNAL after_prepare_reached WAIT_FOR continue"; +--send INSERT INTO t1 VALUES (7) + +--connection default +SET DEBUG_SYNC = "now WAIT_FOR after_prepare_reached"; +--source include/kill_mysqld.inc +--source wsrep-recover-step.inc +if ($log_bin) { + --echo Expect seqno 2 +} +if (!$log_bin) { + --echo Expect seqno 3 +} +--echo $wsrep_recover_start_position_seqno +--let $restart_parameters = --wsrep-start-position=$wsrep_recover_start_position_uuid:$wsrep_recover_start_position_seqno +--source include/start_mysqld.inc +--source include/wait_wsrep_ready.inc + +if ($log_bin) { + --echo Expect 5 +} +if (!$log_bin) { + --echo Expect 5 7 +} +SELECT * FROM t1; + +DROP TABLE t1; |