Debian Codegraph @

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

raw
1 ###############################################################################
2 #
3 # This test confirm that an implicit TRUNCATE statement is managed by Group
4 # Replication when a replicated memory table is first updated after a server
5 # crash or a server restart.
6 #
7 # Test:
8 # 0. The test requires two serves
9 # 1. Create table t1 with engine set to memory on server1
10 # 2. Restart server1 and start group replication
11 # 3. Create a new table based on t1. This will create an
12 # implicit commit due previous restart
13 # 4. Wait for GTID_EXECUTED has 6 gtids
14 # 5. On binary log from first start we shall have: two
15 # views and a create table.
16 # 6. On binary log from second start we shall have: a view,
17 # a truncate table and a create table
18 # 7. On server 2 binary log we shall have: two views, a
19 # create table, a view, a truncate table and a create table
20 # 8. Cleanup
21 #
22 ###############################################################################
23 --source include/have_group_replication_plugin.inc
24 --source include/group_replication.inc
25
26
27 --echo
28 --echo ############################################################
29 --echo # 1. Create table t1 with engine set to memory on server1
30
31 CREATE TABLE t1(a INT, b INT) engine=memory;
32
33 --source include/rpl_sync.inc
34
35
36 --echo
37 --echo ############################################################
38 --echo # 2. Restart server1 and start group replication
39
40 --let $allow_rpl_inited=1
41 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
42 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
43 --let $restart_parameters=restart:--group-replication-group-name=$group_replication_group_name --group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds
44 --replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
45 --source include/restart_mysqld.inc
46
47 --let $rpl_server_number= 1
48 --source include/rpl_reconnect.inc
49
50 --source include/start_group_replication.inc
51
52
53 --echo
54 --echo ############################################################
55 --echo # 3. Create a new table based on t1. This will create an
56 --echo # implicit commit due previous restart
57
58 CREATE TABLE t2 LIKE t1;
59
60 --source include/rpl_sync.inc
61
62 --echo
63 --echo ############################################################
64 --echo # 4. Wait for GTID_EXECUTED has 6 gtids
65
66 --let $wait_condition= SELECT @@GLOBAL.GTID_EXECUTED = "$group_replication_group_name:1-6"
67 --source include/wait_condition.inc
68
69
70 --echo
71 --echo ############################################################
72 --echo # 5. On binary log from first start we shall have: two
73 --echo # views and a create table.
74
75 # The sequence of events that make up a View Change
76 --let $vcle_seq= Gtid # Query/BEGIN # View_change # Query/COMMIT
77
78 # limit to remove match with stop on last line
79 --let $limit= 0, 12
80 --let $binlog_file= server-binary-log.000001
81 --let $event_sequence= $vcle_seq # $vcle_seq # Gtid # !Q(CREATE.*)
82 --source include/assert_binlog_events.inc
83
84
85 --echo
86 --echo ############################################################
87 --echo # 6. On binary log from second start we shall have: a view,
88 --echo # a truncate table and a create table
89
90 --let $binlog_file= server-binary-log.000002
91 --let $event_sequence= $vcle_seq # Gtid # !Q(TRUNCATE.*) # Gtid # !Q(CREATE.*)
92 --source include/assert_binlog_events.inc
93
94
95 --echo
96 --echo ############################################################
97 --echo # 7. On server 2 binary log we shall have: two views, a
98 --echo # create table, a view, a truncate table and a create table
99
100 --let $rpl_connection_name= server2
101 --source include/rpl_connection.inc
102
103 --let $limit=
104 --let $binlog_file= server-binary-log.000001
105 --let $event_sequence= $vcle_seq # $vcle_seq # Gtid # !Q(CREATE.*) # $vcle_seq # Gtid # !Q(TRUNCATE.*) # Gtid # !Q(CREATE.*)
106 --source include/assert_binlog_events.inc
107
108
109 --echo
110 --echo ############################################################
111 --echo # 8. Cleanup
112
113 DROP TABLE t1;
114 DROP TABLE t2;
115
116 --source include/group_replication_end.inc