Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that transactions with GTID_NEXT specified do behave
3 # properly when present to conflicts and/or before commit errors.
4 #
5 # Test:
6 # 0. The test requires two servers: M1 and M2.
7 # 1. With both members ONLINE. Execute some transactions on M1.
8 # 2. On M2 set DEBUG point to force negative certification outcome of the next
9 # transaction. Set DEBUG point on M1.
10 # - With GTID_NEXT set, try to insert data. It must fail.
11 # - Reset DEBUG point and GTID_NEXT.
12 # - Now, insert data must succeed.
13 # - Validate data and GTID_EXECUTED on the member.
14 # 3. On M1 set DEBUG point to force error on before commit hook.
15 # - With GTID_NEXT set, try to insert data. It must fail.
16 # - Try FLUSH RELAY LOGS command. It must fail.
17 # - Reset DEBUG point and GTID_NEXT.
18 # - Now, insert data must succeed.
19 # - Validate data and GTID_EXECUTED on the member.
20 # 4. Clean up.
21 ################################################################################
22 --source include/have_debug.inc
23 --source include/have_group_replication_plugin.inc
24 --source include/group_replication.inc
25
26
27 --echo
28 --echo ############################################################
29 --echo # 1. Execute some transactions on server 1 with and without
30 --echo # GTID specified.
31 --let $rpl_connection_name= server1
32 --source include/rpl_connection.inc
33 SET SESSION sql_log_bin= 0;
34 --source include/gtid_utils.inc
35 SET SESSION sql_log_bin= 1;
36
37 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
38 --source include/rpl_sync.inc
39
40
41 --echo
42 --echo ############################################################
43 --echo # 2. Force negative certification outcome of the next
44 --echo # transaction.
45 --let $rpl_connection_name= server2
46 --source include/rpl_connection.inc
47 SET @debug_save= @@GLOBAL.DEBUG;
48 SET @@GLOBAL.DEBUG= '+d,certifier_force_1_negative_certification';
49 --let $rpl_connection_name= server1
50 --source include/rpl_connection.inc
51 SET @debug_save= @@GLOBAL.DEBUG;
52 SET @@GLOBAL.DEBUG= '+d,certifier_force_1_negative_certification';
53
54 SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb:1';
55 --error ER_TRANSACTION_ROLLBACK_DURING_COMMIT
56 INSERT INTO t1 VALUES (1);
57
58 --let $assert_text= 'GTID_OWNED is empty'
59 --let $assert_cond= "[SELECT @@SESSION.GTID_OWNED]" = ""
60 --source include/assert.inc
61
62 SET GTID_NEXT= AUTOMATIC;
63
64 --let $rpl_connection_name= server2
65 --source include/rpl_connection.inc
66 SET @@GLOBAL.DEBUG= @debug_saved;
67 --let $rpl_connection_name= server1
68 --source include/rpl_connection.inc
69 SET @@GLOBAL.DEBUG= @debug_saved;
70
71 INSERT INTO t1 VALUES (2);
72
73 --let $assert_text= 'There is no value 1 in table t1'
74 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 0
75 --source include/assert.inc
76 --let $assert_text= 'There is a value 2 in table t1'
77 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 2, count, 1] = 1
78 --source include/assert.inc
79
80 --let $assert_text= GTID_EXECUTED must contain 4 group transactions
81 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED,"$group_replication_group_name:1-4")
82 --source include/assert.inc
83
84
85 --echo
86 --echo ############################################################
87 --echo # 3. Force error on before commit hook.
88 SET SESSION sql_log_bin= 0;
89 call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
90 SET SESSION sql_log_bin= 1;
91
92 SET @@GLOBAL.DEBUG= '+d,group_replication_force_error_on_before_commit_listener';
93 SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb:2';
94 --error ER_RUN_HOOK_ERROR
95 INSERT INTO t1 VALUES (3);
96
97 --let $assert_text= 'GTID_OWNED is empty'
98 --let $assert_cond= "[SELECT @@SESSION.GTID_OWNED]" = ""
99 --source include/assert.inc
100
101 SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-bbbbbbbbbbbb:3';
102 --error ER_RUN_HOOK_ERROR
103 FLUSH RELAY LOGS;
104
105 --let $assert_text= 'GTID_OWNED is empty'
106 --let $assert_cond= "[SELECT @@SESSION.GTID_OWNED]" = ""
107 --source include/assert.inc
108
109 SET GTID_NEXT= AUTOMATIC;
110 SET @@GLOBAL.DEBUG= @debug_saved;
111
112 INSERT INTO t1 VALUES (4);
113
114 --let $assert_text= 'There is no value 3 in table t1'
115 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 3, count, 1] = 0
116 --source include/assert.inc
117 --let $assert_text= 'There is a value 4 in table t1'
118 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 4, count, 1] = 1
119 --source include/assert.inc
120
121 --let $assert_text= GTID_EXECUTED must contain 5 group transactions
122 --let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED,"$group_replication_group_name:1-5")
123 --source include/assert.inc
124
125
126 --echo
127 --echo ############################################################
128 --echo # 4. Clean up.
129 DROP TABLE t1;
130
131 SET SESSION sql_log_bin= 0;
132 --source include/gtid_utils_end.inc
133 SET SESSION sql_log_bin= 1;
134
135 --source include/group_replication_end.inc