Debian Codegraph @

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

raw
1 ################################################################################
2 #
3 # GTID_PURGED can't be set while GR plugin is running. This test shall verify
4 # that.
5 #
6 # Test:
7 # 0) The test requires two servers: M1 and M2.
8 # 1) Execute a few transactions locally on M1 before starting GR.
9 # 2) Set GTID_PURGED a few transactions ahead on M1.
10 # 3) Start GR on both members and verify that the group stabilizes itself.
11 # 4) Try to modify the GTID_PURGED with GR running. It should fail with
12 # ER_UPDATE_GTID_PURGED_WITH_GR on each member.
13 # 5) Stop GR and verify that it is possible to set GTID_PURGED again on both
14 # members.
15 # 6) Cleanup.
16 #
17 ################################################################################
18 --let $group_replication_group_name = 7c4f89da-55d2-4a9a-8aa1-b9e854dcf286
19 --source include/have_group_replication_plugin.inc
20 #--source include/big_test.inc
21
22 --echo
23 --echo #########################################################################
24 --echo # 0) The test requires two servers: M1 and M2.
25 --echo #########################################################################
26 --echo
27 --let $rpl_skip_group_replication_start = 1
28 --source include/group_replication.inc
29
30 --echo
31 --echo #########################################################################
32 --echo # 1) Execute a few transactions locally on M1 before starting GR.
33 --echo #########################################################################
34 --echo
35 CREATE TABLE t1(a INT PRIMARY KEY);
36 INSERT INTO t1 VALUES (1);
37 INSERT INTO t1 VALUES (2);
38 INSERT INTO t1 VALUES (3);
39
40 --echo
41 --echo #########################################################################
42 --echo # 2) Set GTID_PURGED a few transactions ahead on M1.
43 --echo #########################################################################
44 --echo
45 --let $member1_uuid = `SELECT @@GLOBAL.server_uuid`
46 SET sql_log_bin = 0;
47 --source include/gtid_utils.inc
48 SET sql_log_bin = 1;
49 RESET MASTER;
50 --eval SET GLOBAL GTID_PURGED = "$group_replication_group_name:1-3"
51 --let $assert_text = GTID_PURGED should contain the first 3 transactions
52 --let $assert_cond = GTID_IS_EQUAL(@@GLOBAL.GTID_PURGED, "$group_replication_group_name:1-3")
53 --source include/assert.inc
54 RESET MASTER;
55
56 --echo
57 --echo #########################################################################
58 --echo # 3) Start GR on both members and verify that the group stabilizes
59 --echo # itself.
60 --echo #########################################################################
61 --echo
62 --source include/start_and_bootstrap_group_replication.inc
63 --source include/rpl_sync.inc
64 --let $rpl_connection_name= server2
65 --source include/rpl_connection.inc
66 SET sql_log_bin = 0;
67 --source include/gtid_utils.inc
68 SET sql_log_bin = 1;
69 --let $member2_uuid = `SELECT @@GLOBAL.server_uuid`
70 --source include/start_group_replication.inc
71
72 --echo
73 --echo #########################################################################
74 --echo # 4) Try to modify the GTID_PURGED with GR running. It should fail with
75 --echo # ER_UPDATE_GTID_PURGED_WITH_GR on each member.
76 --echo #########################################################################
77 --echo
78 --let $rpl_connection_name= server1
79 --source include/rpl_connection.inc
80 --error ER_UPDATE_GTID_PURGED_WITH_GR
81 --eval SET GLOBAL GTID_PURGED = "$group_replication_group_name:4"
82 --let $assert_text = GTID_PURGED should contain the 4th transaction
83 --let $assert_cond = GTID_IS_EQUAL(@@GLOBAL.GTID_PURGED, "")
84 --source include/assert.inc
85
86 --echo
87 --echo #########################################################################
88 --echo # 5) Stop GR and verify that it is possible to set GTID_PURGED again on
89 --echo # both members.
90 --echo #########################################################################
91 --echo
92 --source include/stop_group_replication.inc
93 --eval SET GLOBAL GTID_PURGED = "$group_replication_group_name:4"
94 --let $assert_text = GTID_PURGED should contain the 4th transaction
95 --let $assert_cond = GTID_IS_EQUAL(@@GLOBAL.GTID_PURGED, "$group_replication_group_name:4")
96 --source include/assert.inc
97 --let $rpl_connection_name= server2
98 --source include/rpl_connection.inc
99 --source include/stop_group_replication.inc
100 --eval SET GLOBAL GTID_PURGED = "$group_replication_group_name:4"
101 SELECT @@GLOBAL.GTID_PURGED;
102 --let $assert_text = GTID_PURGED should contain the 4th transaction
103 --let $assert_cond = GTID_IS_EQUAL(@@GLOBAL.GTID_PURGED, "$group_replication_group_name:4")
104 --source include/assert.inc
105
106 --echo
107 --echo #########################################################################
108 --echo # 6) Cleanup.
109 --echo #########################################################################
110 --echo
111 --let $rpl_connection_name= server1
112 --source include/rpl_connection.inc
113 DROP TABLE t1;
114 SET SESSION sql_log_bin= 0;
115 --source include/gtid_utils_end.inc
116 SET SESSION sql_log_bin= 1;
117 --let $rpl_connection_name= server2
118 --source include/rpl_connection.inc
119 SET SESSION sql_log_bin= 0;
120 --source include/gtid_utils_end.inc
121 SET SESSION sql_log_bin= 1;
122 --source include/group_replication_end.inc