Debian Codegraph @

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

raw
1 ################################################################################
2 # Check that local pipeline errors are properly detected and handled.
3 # This test checks that local transactions waiting for certification will
4 # rollback when the applier encounters an error.
5 #
6 # Test:
7 # 0) The test requires two servers: M1 and M2.
8 # 1) Create a group with 2 members and bring them ONLINE. On M1 create a table.
9 # 2) Create a DEBUG point in M1 to force the applier to error out before the
10 # next certification.
11 # 3) Do an insert on M1. As the applier will fail and not certify the
12 # transaction, the query should rollback.
13 # 4) The query should not be on M1.
14 # - Assert check that transaction rolled back locally on M1.
15 # - Assert check M1 is in read mode i.e. super_read_only=1.
16 # 5) Remove DEBUG point and stop GR on M1. Start GR on M1.
17 # - Check that after restarting the service, the value is now on the table.
18 # - Check that GTID_EXECUTED on M1 contains all transactions.
19 # - Check that GTID_EXECUTED on M2 contains all transactions.
20 # 6) Cleanup.
21 ################################################################################
22
23 --source include/big_test.inc
24 --source include/have_debug.inc
25 --source include/have_group_replication_plugin.inc
26 --source include/group_replication.inc
27
28 --echo #
29 --echo # 2 member group
30 --echo # Force a pipeline error on certification handler.
31 --echo #
32
33 --let $rpl_connection_name= server1
34 --source include/rpl_connection.inc
35
36 SET SESSION sql_log_bin= 0;
37 call mtr.add_suppression("Failed to fetch Transaction_context_log_event containing required transaction info for certification");
38 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
39 call mtr.add_suppression("Error at event handling! Got error: 1");
40 call mtr.add_suppression("The member is leaving a group without being on one");
41 call mtr.add_suppression("Due to a plugin error, some transactions were unable to be certified and will now rollback.");
42 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
43 call mtr.add_suppression("Error while waiting for conflict detection procedure to finish on session .*");
44 call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
45 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
46 SET SESSION sql_log_bin= 1;
47
48 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
49
50 SET @@GLOBAL.DEBUG= '+d,certification_handler_force_error_on_pipeline';
51
52 --echo #
53 --echo # Execute a transaction on member 1 causing the applier to error out
54 --echo # The member should leave the group
55 --echo #
56
57 --error ER_TRANSACTION_ROLLBACK_DURING_COMMIT, ER_RUN_HOOK_ERROR
58 INSERT INTO t1 VALUES (1);
59
60 --echo #
61 --echo # Wait until member 1 Group Replication applier errors out.
62 --echo #
63
64 --let $wait_condition= SELECT service_state="OFF" FROM performance_schema.replication_applier_status WHERE channel_name="group_replication_applier"
65 --source include/wait_condition.inc
66
67 --let $group_replication_member_state= ERROR
68 --source include/gr_wait_for_member_state.inc
69
70 --echo #
71 --echo # Assert that the transaction was roll backed locally
72 --echo #
73
74 --let $assert_text= 'There is no value 1 in table t1'
75 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 0
76 --source include/assert.inc
77
78 --echo #
79 --echo # Assert that the read mode is active
80 --echo #
81
82 --let $assert_text= The super_read_only mode should be active.
83 --let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 1;
84 --source include/assert.inc
85
86 --echo #
87 --echo # Stop the member and join it again.
88 --echo #
89
90 SET @@GLOBAL.DEBUG= '-d,certification_handler_force_error_on_pipeline';
91
92 --source include/stop_group_replication.inc
93 --source include/start_group_replication.inc
94
95 --echo #
96 --echo # Check that table 1 now has a value
97 --echo #
98
99 --let $assert_text= 'There is now a value 1 in table t1'
100 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
101 --source include/assert.inc
102
103 --echo #
104 --echo # Check that GTID_EXECUTED on server 1 contains all transactions.
105 --echo #
106
107 --let $assert_text= GTID_EXECUTED must contain all committed GTIDs
108 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-5"
109 --source include/assert.inc
110
111
112 --echo #
113 --echo # Check that GTID_EXECUTED on server 2 contains all transactions.
114 --echo #
115
116 --let $rpl_connection_name= server2
117 --source include/rpl_connection.inc
118 --let $assert_text= GTID_EXECUTED must contain all committed GTIDs
119 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-5"
120 --source include/assert.inc
121
122 --echo #
123 --echo # Test cleanup.
124 --echo #
125
126 DROP TABLE t1;
127 --source include/group_replication_end.inc