Debian Codegraph @

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

raw
1 # WL#6591 Restore backup on existing GTID-aware server - make
2 # GTID_PURGED settable always
3 #
4 # The tests demonstrate GTID_PURGED is indeed settable
5 # through mysqldump restore despite GTID_EXECUTED is not empty.
6 # Specifically a backup could be restored at any point in run time
7 # provided that its gtid description satisfy constraints specified by the WL.
8 # Namely,
9 # In the append syntax case of
10 # SET GTID_PURGED = "+<gtid_set>"
11 # which is generated by mysqldump the assigned value must be disjoint with
12 # the current values of @@GLOBAL.GTID_EXECUTED and @@GLOBAL.GTID_OWNED.
13 #
14 # The result of the assignment operator and the function work shall be:
15 # - GTID_PURGED becomes the union of GTID_PURGED and <gtid_set>.
16 # - GTID_EXECUTED becomes the union of GTID_EXECUTED and <gtid_set>.
17 #
18 # NOTE that the test needs the master side opt file to require the master server
19 # restart to ensure no, even zombie, dump thread crawls into its
20 # execution environment from a previous test.
21 # That would prevent a successful PURGE.
22
23 --source include/not_group_replication_plugin.inc
24 --let $rpl_skip_start_slave= 1
25 --source include/master-slave.inc
26
27 # The following steps are performed below.
28 #
29 # 1. On master, create backup which will have SET @@GTID_PURGED
30 # (the gtid signature).
31 # 2. On the slave server, restore it.
32 # 3. On the slave server, configure auto-position=on connection to the master
33 # and successfully start replication.
34 #
35 # Step 1 verifies
36 # the increment syntax of GTID_PURGED assignment. Such way
37 # composed assignment must be always accepted on a slave; and
38 # Step 2 is supposed to prove GTID_PURGED settability in spite of non-empty
39 # GTID_EXECUTED.
40 # Step 3 is to prove dump restore is compable with auto-position replication.
41 #
42
43 # The slave is clean
44 --source include/rpl_connection_slave.inc
45 --source include/gtid_utils.inc
46 --let $rpl_only_running_threads= 1
47 --let $rpl_no_start_slave=1
48 --source include/rpl_reset.inc
49
50 # Step 1, dump
51
52 --source include/rpl_connection_master.inc
53 RESET MASTER;
54
55 # Dump's data
56 CREATE DATABASE db;
57 CREATE TABLE db.t (a INT);
58 INSERT INTO db.t SET a=1;
59 FLUSH LOGS;
60 --let $new_log=query_get_value(SHOW MASTER STATUS, File, 1)
61 --eval PURGE BINARY LOGS TO '$new_log'
62 # Purge may be ineffective, make sure that's not the case with the following show:
63 SHOW WARNINGS;
64
65 --exec $MYSQL_DUMP --compact --set-gtid-purged=auto --databases db > $MYSQL_TMP_DIR/wl6591_db_dump.sql
66
67 # Step 2, restore.
68
69 --source include/rpl_connection_slave.inc
70
71 # Make the slave to execute some gtids
72 SET @@GTID_NEXT='11111111-1111-1111-1111-111111111111:1';
73 BEGIN;
74 COMMIT;
75 SET @@GTID_NEXT=AUTOMATIC;
76
77 --exec $MYSQL_SLAVE --force < $MYSQL_TMP_DIR/wl6591_db_dump.sql
78 --remove_file $MYSQL_TMP_DIR/wl6591_db_dump.sql
79
80 # Step 3, replication part.
81
82 --source include/rpl_connection_slave.inc
83 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 1;
84 --source include/start_slave.inc
85
86 --source include/rpl_connection_master.inc
87 DROP DATABASE db;
88
89 --source include/sync_slave_sql_with_master.inc
90
91 # Conclusion:
92 # Executed and Purged on the master and the slave are equal
93
94 --source include/rpl_connection_master.inc
95
96 # Sync with the slave that earlier executed this following trx:
97 SET @@GTID_NEXT='11111111-1111-1111-1111-111111111111:1';
98 BEGIN;
99 COMMIT;
100 SET @@GTID_NEXT=AUTOMATIC;
101
102 --source include/sync_slave_sql_with_master.inc
103
104 --source include/rpl_connection_master.inc
105
106 --let $master_gtid_purged=`SELECT @@GLOBAL.gtid_purged`
107 --let $master_gtid_executed=`SELECT @@GLOBAL.gtid_executed`
108
109 --source include/rpl_connection_slave.inc
110
111 --let $is_equal= `SELECT GTID_IS_EQUAL('$master_gtid_purged', @@GLOBAL.gtid_purged)`
112 --let $assert_text= The slave's GTID_PURGED must be equal to the master's one
113 --let $assert_cond= $is_equal
114 --source include/assert.inc
115
116 --let $is_equal= `SELECT GTID_IS_EQUAL('$master_gtid_executed', @@GLOBAL.gtid_executed)`
117 --let $assert_text= The slave's GTID_EXECUTED must be equal to the master's one
118 --let $assert_cond= $is_equal
119 --source include/assert.inc
120
121 --source include/gtid_utils_end.inc
122
123 # Cleanup: is already done
124
125 --source include/rpl_end.inc