File: gr_local_applier_error.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (127 lines) | stat: -rw-r--r-- 4,872 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
################################################################################
# Check that local pipeline errors are properly detected and handled.
# This test checks that local transactions waiting for certification will
# rollback when the applier encounters an error.
#
# Test:
# 0) The test requires two servers: M1 and M2.
# 1) Create a group with 2 members and bring them ONLINE. On M1 create a table.
# 2) Create a DEBUG point in M1 to force the applier to error out before the
#    next certification.
# 3) Do an insert on M1. As the applier will fail and not certify the
#    transaction, the query should rollback.
# 4) The query should not be on M1.
#  - Assert check that transaction rolled back locally on M1.
#  - Assert check M1 is in read mode i.e. super_read_only=1.
# 5) Remove DEBUG point and stop GR on M1. Start GR on M1.
#  - Check that after restarting the service, the value is now on the table.
#  - Check that GTID_EXECUTED on M1 contains all transactions.
#  - Check that GTID_EXECUTED on M2 contains all transactions.
# 6) Cleanup.
################################################################################

--source include/big_test.inc
--source include/have_debug.inc
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc

--echo #
--echo # 2 member group
--echo # Force a pipeline error on certification handler.
--echo #

--let $rpl_connection_name= server1
--source include/rpl_connection.inc

SET SESSION sql_log_bin= 0;
call mtr.add_suppression("Failed to fetch Transaction_context_log_event containing required transaction info for certification");
call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
call mtr.add_suppression("Error at event handling! Got error: 1");
call mtr.add_suppression("The member is leaving a group without being on one");
call mtr.add_suppression("Due to a plugin error, some transactions were unable to be certified and will now rollback.");
call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
call mtr.add_suppression("Error while waiting for conflict detection procedure to finish on session .*");
call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
SET SESSION sql_log_bin= 1;

CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;

SET @@GLOBAL.DEBUG= '+d,certification_handler_force_error_on_pipeline';

--echo #
--echo # Execute a transaction on member 1 causing the applier to error out
--echo # The member should leave the group
--echo #

--error ER_TRANSACTION_ROLLBACK_DURING_COMMIT, ER_RUN_HOOK_ERROR
INSERT INTO t1 VALUES (1);

--echo #
--echo # Wait until member 1 Group Replication applier errors out.
--echo #

--let $wait_condition= SELECT service_state="OFF" FROM performance_schema.replication_applier_status WHERE channel_name="group_replication_applier"
--source include/wait_condition.inc

--let $group_replication_member_state= ERROR
--source include/gr_wait_for_member_state.inc

--echo #
--echo # Assert that the transaction was roll backed locally
--echo #

--let $assert_text= 'There is no value 1 in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 0
--source include/assert.inc

--echo #
--echo # Assert that the read mode is active
--echo #

--let $assert_text= The super_read_only mode should be active.
--let $assert_cond= "[SELECT @@GLOBAL.super_read_only]" = 1;
--source include/assert.inc

--echo #
--echo # Stop the member and join it again.
--echo #

SET @@GLOBAL.DEBUG= '-d,certification_handler_force_error_on_pipeline';

--source include/stop_group_replication.inc
--source include/start_group_replication.inc

--echo #
--echo # Check that table 1 now has a value
--echo #

--let $assert_text= 'There is now a value 1 in table t1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
--source include/assert.inc

--echo #
--echo # Check that GTID_EXECUTED on server 1 contains all transactions.
--echo #

--let $assert_text= GTID_EXECUTED must contain all committed GTIDs
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-5"
--source include/assert.inc


--echo #
--echo # Check that GTID_EXECUTED on server 2 contains all transactions.
--echo #

--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $assert_text= GTID_EXECUTED must contain all committed GTIDs
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$group_replication_group_name:1-5"
--source include/assert.inc

--echo #
--echo # Test cleanup.
--echo #

DROP TABLE t1;
--source include/group_replication_end.inc