| 1 |
#Want to skip this test from daily Valgrind execution |
| 2 |
--source include/no_valgrind_without_big.inc |
| 3 |
# Adding big test option for this test. |
| 4 |
--source include/big_test.inc |
| 5 |
--source include/not_group_replication_plugin.inc |
| 6 |
# ==== Purpose ==== |
| 7 |
# |
| 8 |
# Test that @@GLOBAL.GTID_PURGED is maintained correctly when the server |
| 9 |
# restarts and when logs are purged. |
| 10 |
# |
| 11 |
# @@GLOBAL.GTID_PURGED contains the GTIDs that were in binary logs that |
| 12 |
# have been purged. It is initialized at server start and updated |
| 13 |
# each time logs are purged. |
| 14 |
# |
| 15 |
# Test that GTID_PURGED is: |
| 16 |
# - updated when a log is purged |
| 17 |
# - initialized when the server is started |
| 18 |
# - initialized correctly even when the first binlog begins with a |
| 19 |
# truncated Previous_gtids_log_event |
| 20 |
# - initialized correctly even when the first binlog is truncated |
| 21 |
# before the Previous_gtids_log_event |
| 22 |
# |
| 23 |
# ==== Implementation ==== |
| 24 |
# |
| 25 |
# Make three big iterations: |
| 26 |
# - first, the server behaves normally and generates a Gtid_log_event |
| 27 |
# - second, the server generates a binlog that is truncated in the |
| 28 |
# middle of the Gtid_log_event |
| 29 |
# - third, the server generates a binlog that is truncated just before |
| 30 |
# the Gtid_log_event |
| 31 |
# |
| 32 |
# Each big iteration has two phases: |
| 33 |
# - In the first phase, we generate a sequence of binlogs. |
| 34 |
# - In the second phase, we purge the binlogs, one at a time, and |
| 35 |
# verify that GTID_PURGED is updated accordingly. |
| 36 |
# |
| 37 |
# In the first phase, we have three nested loops: |
| 38 |
# - The innermost loop generates a sequence of transactions. |
| 39 |
# - The middle loop executes FLUSH LOGS before and after invoking the |
| 40 |
# innermost loop. |
| 41 |
# - The outermost loop restarts the server after invoking the middle |
| 42 |
# loop. |
| 43 |
# |
| 44 |
# ==== References ==== |
| 45 |
# |
| 46 |
# Added in WL#3584 - Global Transaction Identifiers |
| 47 |
|
| 48 |
--let $rpl_gtid_utils= 1 |
| 49 |
--source include/master-slave.inc |
| 50 |
--source include/have_debug.inc |
| 51 |
|
| 52 |
--echo ######## Initialize ######## |
| 53 |
|
| 54 |
--let $master_uuid= `SELECT @@SERVER_UUID` |
| 55 |
CREATE TABLE t1 (a INT) ENGINE = InnoDB; |
| 56 |
--source include/sync_slave_sql_with_master.inc |
| 57 |
|
| 58 |
--let $corruption_mode_count= 2 |
| 59 |
--let $restart_count= 2 |
| 60 |
--let $flush_count= 2 |
| 61 |
--let $corruption_mode_flag_1= --debug=d,skip_writing_previous_gtids_log_event |
| 62 |
--let $corruption_mode_flag_2= |
| 63 |
# Does not work: --let $corruption_mode_flag_2= --debug=d,write_partial_previous_gtids_log_event |
| 64 |
|
| 65 |
--let $corruption_mode= 1 |
| 66 |
while ($corruption_mode <= $corruption_mode_count) |
| 67 |
{ |
| 68 |
--echo ######## corruption_mode = $corruption_mode of $corruption_mode_count ######## |
| 69 |
--echo Phase one: Generating logs |
| 70 |
|
| 71 |
--source include/rpl_reset.inc |
| 72 |
|
| 73 |
# Restart the server three times |
| 74 |
--let $restart_i= 1 |
| 75 |
--let $gno= 0 |
| 76 |
while ($restart_i <= $restart_count) |
| 77 |
{ |
| 78 |
--echo ======== restart_i = $restart_i of $restart_count ======== |
| 79 |
|
| 80 |
--connection slave |
| 81 |
--source include/stop_slave.inc |
| 82 |
|
| 83 |
--let $rpl_server_number= 1 |
| 84 |
--let $rpl_start_with_gtids= 1 |
| 85 |
--let $rpl_server_parameters= \$corruption_mode_flag_$corruption_mode |
| 86 |
--source include/rpl_restart_server.inc |
| 87 |
|
| 88 |
--let $rpl_server_parameters= |
| 89 |
--source include/rpl_restart_server.inc |
| 90 |
|
| 91 |
--source include/start_slave.inc |
| 92 |
--connection master |
| 93 |
|
| 94 |
# For each restart, flush the log three times |
| 95 |
--let $flush_i= 1 |
| 96 |
while ($flush_i <= $flush_count) |
| 97 |
{ |
| 98 |
--echo -------- flush_i = $flush_i of $flush_count -------- |
| 99 |
FLUSH LOGS; |
| 100 |
--let $transaction_count= $flush_i |
| 101 |
--let $transaction_i= 1 |
| 102 |
while ($transaction_i <= $transaction_count) |
| 103 |
{ |
| 104 |
--inc $gno |
| 105 |
eval INSERT INTO t1 VALUES ($gno); |
| 106 |
--inc $transaction_i |
| 107 |
} |
| 108 |
FLUSH LOGS; |
| 109 |
|
| 110 |
--echo [on slave] |
| 111 |
--source include/sync_slave_sql_with_master.inc |
| 112 |
|
| 113 |
--let $assert_text= no gtids lost yet on slave |
| 114 |
--let $assert_cond= @@GTID_PURGED = "" |
| 115 |
--source include/assert.inc |
| 116 |
|
| 117 |
--let $assert_text= committed gno $gno on slave |
| 118 |
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$master_uuid:1-$gno") |
| 119 |
--source include/assert.inc |
| 120 |
|
| 121 |
--echo [on master] |
| 122 |
--connection master |
| 123 |
|
| 124 |
--let $assert_text= no gtids lost yet on master |
| 125 |
--let $assert_cond= @@GTID_PURGED = "" |
| 126 |
--source include/assert.inc |
| 127 |
|
| 128 |
--let $assert_text= committed gno $gno on master |
| 129 |
--let $assert_cond= GTID_IS_EQUAL(@@GLOBAL.GTID_EXECUTED, "$master_uuid:1-$gno") |
| 130 |
--source include/assert.inc |
| 131 |
|
| 132 |
--inc $flush_i |
| 133 |
} |
| 134 |
|
| 135 |
--inc $restart_i |
| 136 |
} |
| 137 |
FLUSH LOGS; |
| 138 |
|
| 139 |
--source include/sync_slave_sql_with_master.inc |
| 140 |
--connection master |
| 141 |
|
| 142 |
--echo ######## corruption_mode = $corruption_mode ######## |
| 143 |
--echo Phase two: Purging logs |
| 144 |
--let $gno= 0 |
| 145 |
|
| 146 |
# Purge one log at a time, in the same sequence that we created logs above. |
| 147 |
--let $restart_i= 1 |
| 148 |
while ($restart_i <= $restart_count) |
| 149 |
{ |
| 150 |
--echo ======== restart_i = $restart_i of $restart_count ======== |
| 151 |
|
| 152 |
--source include/purge_first_log.inc |
| 153 |
--let $assert_text= lost gtids from 1 to $gno on master |
| 154 |
--let $assert_cond= GTID_IS_EQUAL(@@GTID_PURGED, "$master_uuid:1-$gno") |
| 155 |
--source include/assert.inc |
| 156 |
|
| 157 |
--source include/purge_first_log.inc |
| 158 |
--let $assert_text= lost gtids from 1 to $gno on master |
| 159 |
--let $assert_cond= GTID_IS_EQUAL(@@GTID_PURGED, "$master_uuid:1-$gno") |
| 160 |
--source include/assert.inc |
| 161 |
|
| 162 |
--let $flush_i= 1 |
| 163 |
while ($flush_i <= $flush_count) |
| 164 |
{ |
| 165 |
# Purge one log for each FLUSH LOGS above. |
| 166 |
--echo -------- flush_i = $flush_i of $flush_count -------- |
| 167 |
--source include/purge_first_log.inc |
| 168 |
--let $assert_text= lost gtids from 1 to $gno on master |
| 169 |
--let $assert_cond= GTID_IS_EQUAL(@@GTID_PURGED, "$master_uuid:1-$gno") |
| 170 |
--source include/assert.inc |
| 171 |
|
| 172 |
# Increase $gno in the same manner as above. |
| 173 |
--let $transaction_count= $flush_i |
| 174 |
--let $transaction_i= 1 |
| 175 |
while ($transaction_i <= $transaction_count) |
| 176 |
{ |
| 177 |
--inc $gno |
| 178 |
--inc $transaction_i |
| 179 |
} |
| 180 |
|
| 181 |
--source include/purge_first_log.inc |
| 182 |
--let $assert_text= lost gtids from 1 to $gno on master |
| 183 |
--let $assert_cond= GTID_IS_EQUAL(@@GTID_PURGED, "$master_uuid:1-$gno") |
| 184 |
--source include/assert.inc |
| 185 |
|
| 186 |
--inc $flush_i |
| 187 |
} |
| 188 |
|
| 189 |
--inc $restart_i |
| 190 |
} |
| 191 |
|
| 192 |
--inc $corruption_mode |
| 193 |
} |
| 194 |
|
| 195 |
--echo ######## Clean up ######## |
| 196 |
--connection master |
| 197 |
DROP TABLE t1; |
| 198 |
--source include/rpl_end.inc |