| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# BUG#16741603: MYSQLD SCANS ALL BINARY LOGS ON CRASH RECOVERY |
| 4 |
# |
| 5 |
# Verify that the server does not scan more than one binary log |
| 6 |
# in every iteration when initializing GTID sets on server start |
| 7 |
# if binlog-gtid-simple-recovery is enabled. See implementation |
| 8 |
# step 1-8. |
| 9 |
# |
| 10 |
# Bug #20075721 ASSERTION `LOST_GTIDS->IS_EMPTY()' AT BINLOG.CC:3637 |
| 11 |
# ON PURGE BINLOG CMD |
| 12 |
# |
| 13 |
# We are hitting the assertion when purging binary logs and the first |
| 14 |
# left binary log just contains a Previous_gtids_log_event. The problem |
| 15 |
# is caused by making GOT_PREVIOUS_GTIDS case to execute the assertion. |
| 16 |
# This change is added after fixing Bug#16741603, but missed to |
| 17 |
# remove the assertion. |
| 18 |
# |
| 19 |
# Removing the assertion to fix the problem. |
| 20 |
# |
| 21 |
# See implementation step 9-10. |
| 22 |
# |
| 23 |
# ==== Implementation ==== |
| 24 |
# |
| 25 |
# 1) Start server and generate four binary logs with gtid_mode off. |
| 26 |
# 2) Move binlog.000002 to binlog.000002.bkp and |
| 27 |
# binlog.000003 to binlog.000003.bkp |
| 28 |
# 3) Only binlog.000001 and binlog.000004 remain, others are moved |
| 29 |
# , restart the server with enabled binlog-gtid-simple-recovery |
| 30 |
# and gtid_mode on. If the server scans more than one binary log in |
| 31 |
# every iteration, it will cause read error on the 2nd and 3rd files. |
| 32 |
# 4) Verify that GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED are empty |
| 33 |
# after server restarts. |
| 34 |
# 5) Move binlog.000004 to binlog.000004.bkp |
| 35 |
# 6) Only binlog.000001 and binlog.000005 remain, others are moved |
| 36 |
# , restart the server with enabled binlog-gtid-simple-recovery |
| 37 |
# and gtid_mode on again. If the server scans more than one binary |
| 38 |
# log in every iteration, it will cause read error on the 2nd and |
| 39 |
# 4th files. |
| 40 |
# 7) Verify that GLOBAL.GTID_EXECUTED contains committed gtid MASTER_UUID:1 |
| 41 |
# and GLOBAL.GTID_PURGED is empty after server restarts again. |
| 42 |
# 8) Move binary logs back. |
| 43 |
# |
| 44 |
# 9) PURGE BINARY LOGS TO the last binary log binlog.000006, which |
| 45 |
# just contains a Previous_gtids_log_event. This will not cause an |
| 46 |
# assertion failure any more. |
| 47 |
# 10) Assert that the set of purged gtids is not empty (it is MASTER_UUID:1), |
| 48 |
# since a gtid event is written into binlog.000004. |
| 49 |
# |
| 50 |
|
| 51 |
# Test in this file is binlog format agnostic, thus no need |
| 52 |
# to rerun them for every format. |
| 53 |
--source include/have_binlog_format_row.inc |
| 54 |
--source include/force_restart.inc |
| 55 |
|
| 56 |
RESET MASTER; |
| 57 |
--let $MYSQLD_DATADIR= `select @@datadir` |
| 58 |
--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 59 |
CREATE TABLE t1 ( |
| 60 |
c1 INT NOT NULL PRIMARY KEY |
| 61 |
); |
| 62 |
|
| 63 |
--echo # Generate binlog.000002 |
| 64 |
FLUSH LOGS; |
| 65 |
INSERT INTO t1 VALUES (1); |
| 66 |
--let $binlog_file2= query_get_value(SHOW MASTER STATUS, File, 1) |
| 67 |
|
| 68 |
--echo # Generate binlog.000003 |
| 69 |
FLUSH LOGS; |
| 70 |
INSERT INTO t1 VALUES (2); |
| 71 |
--let $binlog_file3= query_get_value(SHOW MASTER STATUS, File, 1) |
| 72 |
|
| 73 |
--echo # Generate binlog.000004 |
| 74 |
FLUSH LOGS; |
| 75 |
INSERT INTO t1 VALUES (3); |
| 76 |
--let $binlog_file4= query_get_value(SHOW MASTER STATUS, File, 1) |
| 77 |
|
| 78 |
--echo # Move binlog.000002 to binlog.000002.bkp and |
| 79 |
--echo # binlog.000003 to binlog.000003.bkp |
| 80 |
--move_file $MYSQLD_DATADIR/$binlog_file2 $MYSQLD_DATADIR/$binlog_file2.bkp |
| 81 |
--move_file $MYSQLD_DATADIR/$binlog_file3 $MYSQLD_DATADIR/$binlog_file3.bkp |
| 82 |
|
| 83 |
--echo # |
| 84 |
--echo # Only binlog.000001 and binlog.000004 remain, others are moved |
| 85 |
--echo # , restart the server with enabled binlog-gtid-simple-recovery |
| 86 |
--echo # and gtid_mode on. If the server scans more than one binary log in |
| 87 |
--echo # every iteration, it will cause read error on the 2nd and 3rd files. |
| 88 |
--echo # |
| 89 |
--let $restart_parameters=restart:--gtid-mode=on --enforce-gtid-consistency --log-replica-updates --binlog-gtid-simple-recovery=ON |
| 90 |
--source include/restart_mysqld.inc |
| 91 |
|
| 92 |
--echo # |
| 93 |
--echo # Verify that GLOBAL.GTID_EXECUTED and GLOBAL.GTID_PURGED are empty |
| 94 |
--echo # after server restarts. |
| 95 |
--echo # |
| 96 |
--let $assert_text= GLOBAL.GTID_EXECUTED must be empty. |
| 97 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "" |
| 98 |
--source include/assert.inc |
| 99 |
--let $assert_text= GLOBAL.GTID_PURGED must be empty. |
| 100 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_PURGED]" = "" |
| 101 |
--source include/assert.inc |
| 102 |
|
| 103 |
--echo # |
| 104 |
--echo # Write one gtid event into binlog.000004 |
| 105 |
--echo # |
| 106 |
DROP TABLE t1; |
| 107 |
--echo # Move binlog.000004 to binlog.000004.bkp |
| 108 |
--move_file $MYSQLD_DATADIR/$binlog_file4 $MYSQLD_DATADIR/$binlog_file4.bkp |
| 109 |
|
| 110 |
--echo # |
| 111 |
--echo # Only binlog.000001 and binlog.000005 remain, others are moved |
| 112 |
--echo # , restart the server with enabled binlog-gtid-simple-recovery |
| 113 |
--echo # and gtid_mode on again. If the server scans more than one binary |
| 114 |
--echo # log in every iteration, it will cause read error on the 2nd and |
| 115 |
--echo # 4th files. |
| 116 |
--echo # |
| 117 |
--let $restart_parameters=restart:--gtid-mode=on --enforce-gtid-consistency --log-replica-updates --binlog-gtid-simple-recovery=ON |
| 118 |
--source include/restart_mysqld.inc |
| 119 |
|
| 120 |
--echo # |
| 121 |
--echo # Verify that GLOBAL.GTID_EXECUTED contains committed gtid MASTER_UUID:1 |
| 122 |
--echo # and GLOBAL.GTID_PURGED is empty after server restarts again. |
| 123 |
--echo # |
| 124 |
--let $assert_text= committed gtid MASTER_UUID:1 |
| 125 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1" |
| 126 |
--source include/assert.inc |
| 127 |
--let $assert_text= GLOBAL.GTID_PURGED is empty |
| 128 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_PURGED]" = "" |
| 129 |
--source include/assert.inc |
| 130 |
|
| 131 |
--echo # |
| 132 |
--echo # Move binary logs back. |
| 133 |
--echo # |
| 134 |
--move_file $MYSQLD_DATADIR/$binlog_file2.bkp $MYSQLD_DATADIR/$binlog_file2 |
| 135 |
--move_file $MYSQLD_DATADIR/$binlog_file3.bkp $MYSQLD_DATADIR/$binlog_file3 |
| 136 |
--move_file $MYSQLD_DATADIR/$binlog_file4.bkp $MYSQLD_DATADIR/$binlog_file4 |
| 137 |
|
| 138 |
--let $binlog_file6= query_get_value(SHOW MASTER STATUS, File, 1) |
| 139 |
--echo # |
| 140 |
--echo # PURGE BINARY LOGS TO binlog.000006 |
| 141 |
--echo # |
| 142 |
--eval PURGE BINARY LOGS TO '$binlog_file6' |
| 143 |
|
| 144 |
--let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID` |
| 145 |
--let $assert_text= purged gtids MASTER_UUID:1 |
| 146 |
--let $assert_cond= "[SELECT @@GLOBAL.GTID_PURGED]" = "$master_uuid:1" |
| 147 |
--source include/assert.inc |
| 148 |
|
| 149 |
# clean up |
| 150 |
--let $MYSQLD_DATADIR= |
| 151 |
--let $master_uuid= |
| 152 |
--let $restart_parameters= |
| 153 |
--let $binlog_file2= |
| 154 |
--let $binlog_file3= |
| 155 |
--let $binlog_file4= |
| 156 |
--let $binlog_file6= |