Debian Codegraph @

mysql-test/suite/rpl_gtid/t/mysqldump_bug33630199.test

raw
1 # ===== Purpose =====
2 #
3 # 1) The purpose of this test is to check if the GTIDs, and the data dumped
4 # by mysqldump are consistent. Especially the case when the server has
5 # GTIDs enabled, and there are transactions running in the background,
6 # during the dump.
7 # 2) We've to also make sure that the dump file can be restored on a
8 # GTID aware server.
9 #
10 # ===== Implementation =====
11 #
12 # Consists of 2 steps
13 #
14 # - Step 1 -
15 # 1) Create a test table 't', in database 'db'
16 # 2) Create a stored procedure, which will be called just before mysqldump
17 # is executed. This will help us to mimick a scenario in which there are
18 # transactions going on in the background, while mysqldump is dumping
19 # the databases.
20 # 3) Call the procedure, then start mysqldump just after that
21 #
22 # - Step 2 -
23 # 5) Now restore the dump file to the slave
24 # 6) Execute some statements on the master
25 # 7) Sync master, and slave
26 # 8) The slave's GTID_EXECUTED must be equal to the master's one
27 #
28 # ===== Requirements =====
29 #
30 # 1) The dump captured by mysqldump with --single-transaction and
31 # set-gtid-purged=ON must contain the exact set of transaction GTIDs
32 # that were extracted.
33 # 2) The dump file can be restored without any issue
34 # 3) The replication is working fine
35 # 4) The slave's GTID_EXECUTED must be equal to the master's one
36 # when replication catches up.
37 #
38 # ===== References =====
39 #
40 # Bug#33630199 : mysqldump make a non-consistent backup with
41 # --single-transaction option
42
43 --source include/have_binlog_format_row.inc
44 --let $rpl_gtid_utils= 1
45 --let $rpl_skip_start_slave= 1
46 --disable_warnings
47 --source include/master-slave.inc
48 --enable_warnings
49
50 # Step 1
51 # Running mysqldump, and inserting data into the tables at the same time
52
53 # File, which is going to be used by mysqldump
54 let $mysqldumpfile = $MYSQLTEST_VARDIR/tmp/bug33630199_dump.sql;
55
56 # Create test db
57 CREATE DATABASE db;
58
59 USE db;
60
61 # Create test table
62 CREATE TABLE t(num INT, num2 INT);
63
64 # Create the stored procedure.
65 # We need to keep on sending insert statements to the server,
66 # while on the other session, mysqldump is dumping the data.
67 DELIMITER $;
68
69 CREATE PROCEDURE insertParallely()
70 BEGIN
71 DECLARE counter INT DEFAULT 1;
72 WHILE counter <= 10000 DO
73 INSERT INTO db.t VALUES(counter, 1);
74 SET counter = counter + 1;
75 END WHILE;
76 END$
77
78 DELIMITER ;$
79
80 # Start sending insert statements
81 --send CALL insertParallely();
82
83 --let $rpl_connection_name= server_1
84 --source include/rpl_connection.inc
85
86 # Dump on fast machines could be empty.
87 # Make sure that somethings inserted.
88 --let $wait_condition= SELECT COUNT(*) > 10 FROM db.t
89 --source include/wait_condition.inc
90
91 # Start dump
92 --exec $MYSQL_DUMP --compact --single-transaction --set-gtid-purged=ON -ER --databases db > $mysqldumpfile
93
94 --source include/rpl_connection_master.inc
95
96 --reap
97
98 # End of Step 1
99
100 # Step 2
101 # Restoring the dump file, and syncing master-slave
102
103 --source include/rpl_connection_slave.inc
104
105 --exec $MYSQL_SLAVE --force < $mysqldumpfile
106 --remove_file $mysqldumpfile
107
108 --source include/start_slave.inc
109
110 --source include/rpl_connection_master.inc
111
112 # Make sure that replication is working.
113 # Execute an UPDATE that updates all the table data.
114 # If some data is missing from the dump but not from the GTID set,
115 # replication errors will occur.
116 UPDATE db.t SET num2=2 WHERE num2=1;
117
118 --let $masters_gtid_executed=`SELECT @@GLOBAL.gtid_executed`
119
120 --source include/sync_slave_sql_with_master.inc
121
122 --source include/rpl_connection_slave.inc
123
124 # Conclusion:
125 # Executed GTIDs on the master and the slave are equal
126
127 # Count the rows in 't' with num2=2 on slave, must be 10000
128 --let $row_count = `SELECT 10000 = (SELECT COUNT(*) FROM db.t WHERE num2=2)`
129 --let $assert_text= The row count with num2=2 must be 10000 on slave
130 --let $assert_cond= $row_count
131 --source include/assert.inc
132
133 # GTID_EXECUTED must be equal for both master, and slave
134 --let $is_equal= `SELECT GTID_IS_EQUAL('$masters_gtid_executed', @@GLOBAL.gtid_executed)`
135 --let $assert_text= The slave's GTID_EXECUTED must be equal to the master's one
136 --let $assert_cond= $is_equal
137 --source include/assert.inc
138
139 --source include/rpl_connection_master.inc
140 DROP DATABASE db;
141
142 --source include/rpl_end.inc
143
144 # End of Step 2