Debian Codegraph @

mysql-test/suite/galera/t/galera_mdev_31517.test

raw
1 #
2 # Test for MDEV-31517: Wrong variable name in the configuration leads
3 # Galera to think SST/IST failed, at next restart will request a full
4 # SST.
5 #
6 # To reproduce:
7 #
8 # 1. Start Galera cluster
9 # 2. Stop a Node
10 # 3. Start the node
11 # 4. Stop a Node
12 # 5. Add non_existing_variable=ON in the config
13 # 6. Start the node, this will fail
14 # 7 Remove non_existing_variable=ON from the config file
15 # 8 Restart the server
16 # 9. Observe a full SST happening
17 #
18 # This test checks that an IST takes place at Step 9 instead of a full SST.
19
20 # Step 1: Start Galera cluster
21 --source include/galera_cluster.inc
22 --source include/have_mariabackup.inc
23 --echo # Make sure that the test is operating on the right version of galera library.
24 --let $galera_version=26.4.25
25 source ../wsrep/include/check_galera_version.inc;
26
27 # Save original auto_increment_offset values.
28 --let $node_1=node_1
29 --let $node_2=node_2
30 --source include/auto_increment_offset_save.inc
31
32 # Suppress expected errors and warnings:
33 --connection node_2
34 CALL mtr.add_suppression("unknown variable 'non_existing_variable=ON'");
35 CALL mtr.add_suppression("Aborting");
36 CALL mtr.add_suppression("sst_received failed: State wait was interrupted");
37 CALL mtr.add_suppression("State transfer interrupted, shutting down gracefully");
38
39 # Count the number of "SST completed" messages in the log file before
40 # and after testing. To do this we need to save original log file
41 # before testing:
42 #
43 --let TEST_LOG=$MYSQLTEST_VARDIR/log/mysqld.2.err
44 --perl
45 use strict;
46 my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
47 my $test_log_copy=$test_log . '.copy';
48 if (-e $test_log_copy) {
49 unlink $test_log_copy;
50 }
51 EOF
52 --copy_file $TEST_LOG $TEST_LOG.copy
53
54 --connection node_1
55 CREATE TABLE t(i INT NOT NULL PRIMARY KEY) ENGINE INNODB;
56 INSERT INTO t VALUES(1);
57
58 # Step 2: Stop node 2
59 --connection node_2
60 --source include/shutdown_mysqld.inc
61
62 --connection node_1
63 --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
64 --source include/wait_condition.inc
65
66 # Step 3: Start node 2
67 --connection node_2
68 --source include/start_mysqld.inc
69
70 --connection node_1
71 --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
72 --source include/wait_condition.inc
73
74 # Step 4: Stop node 2
75 --connection node_2
76 let $MYSQLD_DATADIR= `SELECT @@datadir`;
77 --source include/shutdown_mysqld.inc
78
79 --connection node_1
80 --let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
81 --source include/wait_condition.inc
82
83 # Step 5: Add non_existing_variable=ON in the config
84 --exec cp $MYSQLTEST_VARDIR/my.cnf $MYSQLTEST_VARDIR/my.cnf-orig
85 --exec echo '[mysqld.2]' >> $MYSQLTEST_VARDIR/my.cnf
86 --exec echo 'non_existing_variable=ON' >> $MYSQLTEST_VARDIR/my.cnf
87
88 # Step 6: start the stopped node, this will fail
89 --connection node_2
90 --exec cp -p $MYSQLD_DATADIR/grastate.dat $MYSQLD_DATADIR/grastate.dat_before
91 --echo Starting server ...
92 --error 1
93 --exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf | grep 'non_existing_variable'
94 --exec cp -p $MYSQLD_DATADIR/grastate.dat $MYSQLD_DATADIR/grastate.dat_after
95
96 # Step 7: remove the wrong variable in the config file
97 --exec cp $MYSQLTEST_VARDIR/my.cnf-orig $MYSQLTEST_VARDIR/my.cnf
98
99 # Step 8: Start the node
100 --echo Starting server ...
101 let $restart_noprint=2;
102 --source include/start_mysqld.inc
103
104 --let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
105 --source include/wait_condition.inc
106
107 --let $wait_condition = SELECT VARIABLE_VALUE = 'ON' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_ready';
108 --source include/wait_condition.inc
109
110 # cleanup
111 SET GLOBAL wsrep_mode = DEFAULT;
112
113 --connection node_1
114 DROP TABLE t;
115
116 # Count the number of "SST completed" messages in the log file during
117 # test phase - to print the error message if the number of such
118 # messages in log file increased at the end of the test:
119 #
120 --perl
121 use strict;
122 my $test_log=$ENV{'TEST_LOG'} or die "TEST_LOG not set";
123 my $test_log_copy=$test_log . '.copy';
124 open(FILE, $test_log_copy) or die("Unable to open $test_log_copy: $!\n");
125 my $initial=grep(/SST completed/gi,<FILE>);
126 close(FILE);
127 open(FILE, $test_log) or die("Unable to open $test_log: $!\n");
128 my $final=grep(/SST completed/gi,<FILE>);
129 close(FILE);
130 if ($final != $initial) {
131 my $diff=$final-$initial;
132 print("Full WSREP SST performed $diff times.\n");
133 }
134 EOF
135 --remove_file $TEST_LOG.copy
136
137 --source include/auto_increment_offset_restore.inc
138 --source include/galera_end.inc