1#
2# ==== Purpose ====
3#
4# WL#6559 Optimize GTIDs for passive slave - store GTIDs in table
5#
6# Verify that we can store gtids into gtid_executed table for transactions
7# on binlog rotation and report GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED
8# correctly on slave when binlog is enabled and log_slave_updates is diabled.
9#
10
11--source include/not_group_replication_plugin.inc
12--source include/have_gtid.inc
13--source include/have_debug.inc
14--source include/have_debug_sync.inc
15--let $rpl_gtid_utils= 1
16--source include/master-slave.inc
17
18--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
19
20CREATE TABLE IF NOT EXISTS t1 (a INT) ENGINE=InnoDB;
21CREATE TABLE t2 (a INT) ENGINE=MyISAM;
22INSERT INTO t1 VALUES(1);
23INSERT INTO t2 VALUES(1);
24--echo #
25--echo # Verify that transactions' gtids can be reported
26--echo # from global.gtid_executed correctly.
27--echo #
28--let $assert_text= committed gtids MASTER_UUID:1-4
29--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4"
30--source include/assert.inc
31--echo #
32--echo # Store gtids MASTER_UUID:1-4 in gtid_executed table on binlog rotation
33--echo #
34FLUSH LOGS;
35--replace_result $master_uuid MASTER_UUID
36SELECT * FROM mysql.gtid_executed;
37
38
39--source include/sync_slave_sql_with_master.inc
40--echo #
41--echo # connection slave
42--echo #
43--let $slave_uuid= `SELECT @@GLOBAL.SERVER_UUID`
44--let $assert_text= committed gtids MASTER_UUID:1-4
45--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-4"
46--source include/assert.inc
47--echo #
48--echo # Verify that slave thread stores gtid into gtid_executed table within
49--echo # each transaction if binlog is on and log_slave_updated is disabled.
50--echo #
51--replace_result $master_uuid MASTER_UUID
52SELECT * FROM mysql.gtid_executed;
53
54INSERT INTO t1 VALUES(2);
55INSERT INTO t2 VALUES(2);
56--echo #
57--echo # Verify that store gtids SLAVE_UUID:1-2 into gtid_executed table,
58--echo # which is also compressed on binlog rotation.
59--echo #
60
61SET @old_compression_period= @@GLOBAL.GTID_EXECUTED_COMPRESSION_PERIOD;
62SET @@GLOBAL.GTID_EXECUTED_COMPRESSION_PERIOD= 1;
63FLUSH LOGS;
64SET @@GLOBAL.GTID_EXECUTED_COMPRESSION_PERIOD= @old_compression_period;
65
66--let $table= mysql.gtid_executed
67--let $count= 2
68--source include/wait_until_rows_count.inc
69
70--replace_result $master_uuid MASTER_UUID
71--eval SELECT * FROM mysql.gtid_executed where source_uuid="$master_uuid"
72--replace_result $slave_uuid SLAVE_UUID
73--eval SELECT * FROM mysql.gtid_executed where source_uuid="$slave_uuid"
74
75--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
76--echo #
77--echo # Verify that we can get the correct set of gtid_purged when purging
78--echo # logs if binlog is enabled and log_slave_updates is disabled.
79--echo #
80--eval PURGE BINARY LOGS TO '$binlog_file'
81--let $assert_text= purged gtids SLAVE_UUID:1-2,MASTER_UUID:1-4
82--let $assert_cond= GTID_IS_EQUAL("[SELECT @@GLOBAL.GTID_PURGED]", "$slave_uuid:1-2,$master_uuid:1-4")
83--source include/assert.inc
84
85--echo #
86--echo # Verify that we can get the correct set from 'gtid_executed' table
87--echo # when executing a big transaction that exceeds the max size of the
88--echo # binlog if binlog is enabled and log_slave_updates is disabled.
89--echo #
90SET @SIZE_DEFAULT=@@MAX_BINLOG_SIZE;
91SET GLOBAL MAX_BINLOG_SIZE=4096;
92SET @@GLOBAL.DEBUG= '+d, dont_compress_gtid_table';
93
94--let $i= 1
95BEGIN;
96while ($i < 60) {
97  --eval INSERT INTO t1 VALUES ($i);
98  --inc $i
99}
100COMMIT;
101SET GLOBAL DEBUG= @debug_save;
102SET GLOBAL MAX_BINLOG_SIZE=@SIZE_DEFAULT;
103
104--replace_result $master_uuid MASTER_UUID
105--eval SELECT * FROM mysql.gtid_executed where source_uuid="$master_uuid"
106--replace_result $slave_uuid SLAVE_UUID
107--eval SELECT * FROM mysql.gtid_executed where source_uuid="$slave_uuid"
108
109--connection master
110DROP TABLE t1,t2;
111
112--source include/rpl_end.inc
113