File: rpl_gtid_purged_settable.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (125 lines) | stat: -rw-r--r-- 4,118 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# WL#6591 Restore backup on existing GTID-aware server - make
# GTID_PURGED settable always
#
# The tests demonstrate GTID_PURGED is indeed settable
# through mysqldump restore despite GTID_EXECUTED is not empty.
# Specifically a backup could be restored at any point in run time
# provided that its gtid description satisfy constraints specified by the WL.
# Namely,
# In the append syntax case of
#   SET GTID_PURGED = "+<gtid_set>"
# which is generated by mysqldump the assigned value must be disjoint with
# the current values of @@GLOBAL.GTID_EXECUTED and @@GLOBAL.GTID_OWNED.
#
# The result of the assignment operator and the function work shall be:
#    - GTID_PURGED becomes the union of GTID_PURGED and <gtid_set>.
#    - GTID_EXECUTED becomes the union of GTID_EXECUTED and <gtid_set>.
#
# NOTE that the test needs the master side opt file to require the master server
# restart to ensure no, even zombie, dump thread crawls into its
# execution environment from a previous test.
# That would prevent a successful PURGE.

--source include/not_group_replication_plugin.inc
--let $rpl_skip_start_slave= 1
--source include/master-slave.inc

# The following steps are performed below.
#
# 1. On master, create backup which will have SET @@GTID_PURGED
#     (the gtid signature).
# 2. On the slave server, restore it.
# 3. On the slave server, configure auto-position=on connection to the master
#     and successfully start replication.
#
# Step 1 verifies
#          the increment syntax of GTID_PURGED assignment. Such way
#          composed assignment must be always accepted on a slave; and
# Step 2 is supposed to prove GTID_PURGED settability in spite of non-empty
#          GTID_EXECUTED.
# Step 3 is to prove dump restore is compable with auto-position replication.
#

# The slave is clean
--source include/rpl_connection_slave.inc
--source include/gtid_utils.inc
--let $rpl_only_running_threads= 1
--let $rpl_no_start_slave=1
--source include/rpl_reset.inc

# Step 1, dump

--source include/rpl_connection_master.inc
RESET MASTER;

# Dump's data
CREATE DATABASE db;
CREATE TABLE db.t (a INT);
INSERT INTO db.t SET a=1;
FLUSH LOGS;
--let $new_log=query_get_value(SHOW MASTER STATUS, File, 1)
--eval PURGE BINARY LOGS TO '$new_log'
# Purge may be ineffective, make sure that's not the case with the following show:
SHOW WARNINGS;

--exec $MYSQL_DUMP --compact  --set-gtid-purged=auto --databases db > $MYSQL_TMP_DIR/wl6591_db_dump.sql

# Step 2, restore.

--source include/rpl_connection_slave.inc

# Make the slave to execute some gtids
SET @@GTID_NEXT='11111111-1111-1111-1111-111111111111:1';
BEGIN;
COMMIT;
SET @@GTID_NEXT=AUTOMATIC;

--exec $MYSQL_SLAVE --force < $MYSQL_TMP_DIR/wl6591_db_dump.sql
--remove_file $MYSQL_TMP_DIR/wl6591_db_dump.sql

# Step 3, replication part.

--source include/rpl_connection_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION= 1;
--source include/start_slave.inc

--source include/rpl_connection_master.inc
DROP DATABASE db;

--source include/sync_slave_sql_with_master.inc

# Conclusion:
# Executed and Purged on the master and the slave are equal

--source include/rpl_connection_master.inc

# Sync with the slave that earlier executed this following trx:
SET @@GTID_NEXT='11111111-1111-1111-1111-111111111111:1';
BEGIN;
COMMIT;
SET @@GTID_NEXT=AUTOMATIC;

--source include/sync_slave_sql_with_master.inc

--source include/rpl_connection_master.inc

--let $master_gtid_purged=`SELECT @@GLOBAL.gtid_purged`
--let $master_gtid_executed=`SELECT @@GLOBAL.gtid_executed`

--source include/rpl_connection_slave.inc

--let $is_equal= `SELECT GTID_IS_EQUAL('$master_gtid_purged', @@GLOBAL.gtid_purged)`
--let $assert_text= The slave's GTID_PURGED must be equal to the master's one
--let $assert_cond= $is_equal
--source include/assert.inc

--let $is_equal= `SELECT GTID_IS_EQUAL('$master_gtid_executed', @@GLOBAL.gtid_executed)`
--let $assert_text= The slave's GTID_EXECUTED must be equal to the master's one
--let $assert_cond= $is_equal
--source include/assert.inc

--source include/gtid_utils_end.inc

# Cleanup: is already done

--source include/rpl_end.inc