File: binlog_gtid_simple_recovery.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 (156 lines) | stat: -rw-r--r-- 6,002 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# ==== Purpose ====
#
# BUG#16741603: MYSQLD SCANS ALL BINARY LOGS ON CRASH RECOVERY
#
# Verify that the server does not scan more than one binary log
# in every iteration when initializing GTID sets on server start
# if binlog-gtid-simple-recovery is enabled. See implementation
# step 1-8.
#
# Bug #20075721  ASSERTION `LOST_GTIDS->IS_EMPTY()' AT BINLOG.CC:3637
# ON PURGE BINLOG CMD
#
# We are hitting the assertion when purging binary logs and the first
# left binary log just contains a Previous_gtids_log_event. The problem
# is caused by making GOT_PREVIOUS_GTIDS case to execute the assertion.
# This change is added after fixing Bug#16741603, but missed to
# remove the assertion.
#
# Removing the assertion to fix the problem.
#
# See implementation step 9-10.
#
# ==== Implementation ====
#
# 1) Start server and generate four binary logs with gtid_mode off.
# 2) Move binlog.000002 to binlog.000002.bkp and
#    binlog.000003 to binlog.000003.bkp
# 3) Only binlog.000001 and binlog.000004 remain, others are moved
#    , restart the server with enabled binlog-gtid-simple-recovery
#    and gtid_mode on. If the server scans more than one binary log in
#    every iteration, it will cause read error on the 2nd and 3rd files.
# 4) Verify that GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED are empty
#    after server restarts.
# 5) Move binlog.000004 to binlog.000004.bkp
# 6) Only binlog.000001 and binlog.000005 remain, others are moved
#    , restart the server with enabled binlog-gtid-simple-recovery
#    and gtid_mode on again. If the server scans more than one binary
#    log in every iteration, it will cause read error on the 2nd and
#    4th files.
# 7) Verify that GLOBAL.GTID_EXECUTED contains committed gtid MASTER_UUID:1
#    and GLOBAL.GTID_PURGED is empty after server restarts again.
# 8) Move binary logs back.
#
# 9) PURGE BINARY LOGS TO the last binary log binlog.000006, which
#    just contains a Previous_gtids_log_event. This will not cause an
#    assertion failure any more.
# 10) Assert that the set of purged gtids is not empty (it is MASTER_UUID:1),
#     since a gtid event is written into binlog.000004.
#

# Test in this file is binlog format agnostic, thus no need
# to rerun them for every format.
--source include/have_binlog_format_row.inc
--source include/force_restart.inc

RESET MASTER;
--let $MYSQLD_DATADIR= `select @@datadir`
--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
CREATE TABLE t1 (
  c1 INT NOT NULL PRIMARY KEY
);

--echo # Generate binlog.000002
FLUSH LOGS;
INSERT INTO t1 VALUES (1);
--let $binlog_file2= query_get_value(SHOW MASTER STATUS, File, 1)

--echo # Generate binlog.000003
FLUSH LOGS;
INSERT INTO t1 VALUES (2);
--let $binlog_file3= query_get_value(SHOW MASTER STATUS, File, 1)

--echo # Generate binlog.000004
FLUSH LOGS;
INSERT INTO t1 VALUES (3);
--let $binlog_file4= query_get_value(SHOW MASTER STATUS, File, 1)

--echo # Move binlog.000002 to binlog.000002.bkp and
--echo # binlog.000003 to binlog.000003.bkp
--move_file $MYSQLD_DATADIR/$binlog_file2 $MYSQLD_DATADIR/$binlog_file2.bkp
--move_file $MYSQLD_DATADIR/$binlog_file3 $MYSQLD_DATADIR/$binlog_file3.bkp

--echo #
--echo # Only binlog.000001 and binlog.000004 remain, others are moved
--echo # , restart the server with enabled binlog-gtid-simple-recovery
--echo # and gtid_mode on. If the server scans more than one binary log in
--echo # every iteration, it will cause read error on the 2nd and 3rd files.
--echo #
--let $restart_parameters=restart:--gtid-mode=on --enforce-gtid-consistency --log-replica-updates --binlog-gtid-simple-recovery=ON
--source include/restart_mysqld.inc

--echo #
--echo # Verify that GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED are empty
--echo # after server restarts.
--echo #
--let $assert_text= GLOBAL.GTID_EXECUTED must be empty.
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = ""
--source include/assert.inc
--let $assert_text= GLOBAL.GTID_PURGED must be empty.
--let $assert_cond= "[SELECT @@GLOBAL.GTID_PURGED]" = ""
--source include/assert.inc

--echo #
--echo # Write one gtid event into binlog.000004
--echo #
DROP TABLE t1;
--echo # Move binlog.000004 to binlog.000004.bkp
--move_file $MYSQLD_DATADIR/$binlog_file4 $MYSQLD_DATADIR/$binlog_file4.bkp

--echo #
--echo # Only binlog.000001 and binlog.000005 remain, others are moved
--echo # , restart the server with enabled binlog-gtid-simple-recovery
--echo # and gtid_mode on again. If the server scans more than one binary
--echo # log in every iteration, it will cause read error on the 2nd and
--echo # 4th files.
--echo #
--let $restart_parameters=restart:--gtid-mode=on --enforce-gtid-consistency --log-replica-updates --binlog-gtid-simple-recovery=ON
--source include/restart_mysqld.inc

--echo #
--echo # Verify that GLOBAL.GTID_EXECUTED contains committed gtid MASTER_UUID:1
--echo # and GLOBAL.GTID_PURGED is empty after server restarts again.
--echo #
--let $assert_text= committed gtid MASTER_UUID:1
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1"
--source include/assert.inc
--let $assert_text= GLOBAL.GTID_PURGED is empty
--let $assert_cond= "[SELECT @@GLOBAL.GTID_PURGED]" = ""
--source include/assert.inc

--echo #
--echo # Move binary logs back.
--echo #
--move_file $MYSQLD_DATADIR/$binlog_file2.bkp $MYSQLD_DATADIR/$binlog_file2
--move_file $MYSQLD_DATADIR/$binlog_file3.bkp $MYSQLD_DATADIR/$binlog_file3
--move_file $MYSQLD_DATADIR/$binlog_file4.bkp $MYSQLD_DATADIR/$binlog_file4

--let $binlog_file6= query_get_value(SHOW MASTER STATUS, File, 1)
--echo #
--echo # PURGE BINARY LOGS TO binlog.000006
--echo #
--eval PURGE BINARY LOGS TO '$binlog_file6'

--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
--let $assert_text= purged gtids MASTER_UUID:1
--let $assert_cond= "[SELECT @@GLOBAL.GTID_PURGED]" = "$master_uuid:1"
--source include/assert.inc

# clean up
--let $MYSQLD_DATADIR=
--let $master_uuid=
--let $restart_parameters=
--let $binlog_file2=
--let $binlog_file3=
--let $binlog_file4=
--let $binlog_file6=