Debian Codegraph @

mysql-test/suite/group_replication/t/gr_abort_query_on_plugin_recovery.test

raw
1 ################################################################################
2 # This test proves that no query can be executed by a user when the group
3 # replication plugin is on recovery mode as it could cause deadlocks and/or
4 # conflicts.
5 #
6 # To test this, we start a server, but on the donor the applier thread is stopped
7 # so the joiner will be stuck on recovery as the view change packet wont arrive.
8 # While stuck on recovery, we execute a query on this server and check that it
9 # fails
10 #
11 # Test:
12 # 0. The test requires two servers: M1 and M2.
13 # 1. Bootstrap start a group on M1, create a table 't1'.
14 # 2. Start GR on M2. M2 should go to RECOVERING state. Wait for recovery to
15 # create table t1.
16 # 3. Expect ER_OPTION_PREVENTS_STATEMENT on DML execution because M2 is in
17 # super_read_only mode during recovery.
18 # 4. Wait for M2 to come ONLINE and re-execute DML.
19 # 5. Assert check that M1 and M2 have the same data and gtid_executed.
20 # 6. Cleanup.
21 ################################################################################
22
23 --source include/have_debug_sync.inc
24 --let $group_replication_group_name= 49adfac0-b156-11e4-ab27-0800200c9a66
25 --source include/have_group_replication_plugin.inc
26 --let $rpl_skip_group_replication_start= 1
27 --source include/group_replication.inc
28
29 --echo #################################################################
30 --echo # Start group replication on server 1.
31
32 --connection server1
33 --echo server1
34 --source include/start_and_bootstrap_group_replication.inc
35
36 CREATE TABLE test.t1 (a INT NOT NULL AUTO_INCREMENT PRIMARY KEY , b INT);
37
38 --echo
39 --echo #####################################################################
40 --echo # Start group replication on server2 and wait for the state to change.
41
42 --connection server2
43 --echo server2
44
45 set session sql_log_bin=0;
46 call mtr.add_suppression("Transaction cannot be executed while Group Replication is recovering.*");
47 call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
48 set session sql_log_bin=1;
49
50 SET @@GLOBAL.DEBUG='+d,recovery_thread_wait_before_finish';
51
52 --let $group_replication_start_member_state= RECOVERING
53 --source include/start_group_replication.inc
54
55 --echo
56 --echo ###################################################
57 --echo # On server 2 wait for recovery to create the table.
58
59 --let $wait_condition= SELECT count(*) = 1 FROM information_schema.tables WHERE (table_schema = 'test') AND (table_name = 't1');
60 --source include/wait_condition.inc
61
62 --echo
63 --echo ##########################################################
64 --echo # On server 2 try to execute a query and see that it fails as the
65 --echo # server is in super-read-only mode during recovery.
66
67 --error ER_OPTION_PREVENTS_STATEMENT
68 INSERT INTO test.t1 (b) VALUES (1);
69
70 --echo
71 --echo ###################################################################
72 --echo # On server 2 wait for it to become online and re-execute the query
73
74 --connection server2
75 --echo server2
76
77 SET DEBUG_SYNC= "now WAIT_FOR signal.recovery_thread_wait_before_finish_reached";
78 SET @@GLOBAL.DEBUG='-d,recovery_thread_wait_before_finish';
79 SET DEBUG_SYNC= "now SIGNAL signal.recovery_end";
80
81 --let $group_replication_member_state= ONLINE
82 --source include/gr_wait_for_member_state.inc
83
84 SET DEBUG_SYNC= 'RESET';
85
86 INSERT INTO test.t1 (b) VALUES (1);
87
88 --source include/rpl_sync.inc
89
90 --echo
91 --echo #######################################################################
92 --echo # Assert that server1 and server2 have the same data and GTID_EXECUTED.
93
94 --connection server1
95 --echo server1
96 --let $assert_text= 'There is a value 1 in table t1 on server1'
97 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 1
98 --source include/assert.inc
99
100 --connection server2
101 --echo server2
102 --let $assert_text= 'There is a value 1 in table t1 on server2'
103 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1, count, 1] = 1
104 --source include/assert.inc
105
106 --connection server1
107 --echo server1
108 --let $server1_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED`
109 --connection server2
110 --echo server2
111 --let $server2_gtid_executed= `SELECT @@GLOBAL.GTID_EXECUTED`
112 --let $assert_text= 'server1 and server2 GTID_EXECUTED must be equal'
113 --let $assert_cond= "$server1_gtid_executed" = "$server2_gtid_executed"
114 --source include/assert.inc
115
116 --echo
117 --echo #########
118 --echo # Cleanup
119
120 DROP TABLE t1;
121
122 --source include/group_replication_end.inc
123