| 1 |
# |
| 2 |
# WL#9236: Add a new variable binlog_expire_logs_seconds |
| 3 |
# |
| 4 |
# ==== Purpose ==== |
| 5 |
# The test case test the following: |
| 6 |
# |
| 7 |
# 1. If binlog_expire_logs_seconds == 0 and expire_logs_days == 0, no purge |
| 8 |
# happens. |
| 9 |
# |
| 10 |
# 2. In all the below listed cases it puges the binary logs older than the |
| 11 |
# timeout and keeps the binary logs newer than the timeout. |
| 12 |
# |
| 13 |
# 2.1. binlog_expire_logs_seconds > 0 and expire_logs_days > 0 |
| 14 |
# 2.2. binlog_expire_logs_seconds > 0 and expire_logs_days == 0 |
| 15 |
# 2.3. binlog_expire_logs_seconds == 0 and expire_logs_days > 0 |
| 16 |
# |
| 17 |
# Additional tests for the boundaries of expire_logs_days already |
| 18 |
# exist on the sys_vars.expire_logs_days_basic test case. |
| 19 |
# |
| 20 |
# === References === |
| 21 |
# |
| 22 |
# Bug#33670457: Incorrect result when `binlog_expire_logs_seconds` has maximum |
| 23 |
# value in 32 bit |
| 24 |
# |
| 25 |
|
| 26 |
# Test in this file is binlog format agnostic, thus no need |
| 27 |
# to rerun it for every format. |
| 28 |
CALL mtr.add_suppression("The option expire_logs_days cannot be used together*"); |
| 29 |
--source include/have_binlog_format_row.inc |
| 30 |
--source include/not_windows.inc |
| 31 |
--source include/not_binlog_transaction_compression_on.inc |
| 32 |
|
| 33 |
--let $saved_expire_logs_days= `SELECT @@GLOBAL.expire_logs_days` |
| 34 |
--let $saved_binlog_expire_logs_seconds= `SELECT @@GLOBAL.binlog_expire_logs_seconds` |
| 35 |
# Set the datadir |
| 36 |
--let $MYSQLD_DATADIR= `SELECT @@datadir` |
| 37 |
|
| 38 |
--echo #### |
| 39 |
--echo #### 1. When binlog_expire_logs_seconds == 0 and expire_logs_days == 0 |
| 40 |
--echo #### no purge should happen |
| 41 |
|
| 42 |
SET GLOBAL binlog_expire_logs_seconds= 0; |
| 43 |
SET GLOBAL expire_logs_days= 0; |
| 44 |
|
| 45 |
# This will test the expire period for three scenarios, described in the |
| 46 |
# .inc file. |
| 47 |
--source suite/binlog/include/binlog_expire_logs_seconds.inc |
| 48 |
|
| 49 |
--echo #### |
| 50 |
--echo #### 2.1: binlog_expire_logs_seconds > 0 and expire_logs_days == 0 |
| 51 |
--echo #### |
| 52 |
|
| 53 |
# Here we will test both with smaller values and larger values |
| 54 |
|
| 55 |
--echo Testing with smaller values of binlog_expire_logs_seconds |
| 56 |
|
| 57 |
SET GLOBAL binlog_expire_logs_seconds= 30; |
| 58 |
SET GLOBAL expire_logs_days= 0; |
| 59 |
|
| 60 |
--let $expire_logs_seconds= `SELECT @@global.binlog_expire_logs_seconds + @@global.expire_logs_days * 24 * 60 * 60` |
| 61 |
|
| 62 |
--let $first_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 63 |
FLUSH LOGS; |
| 64 |
|
| 65 |
--sleep $expire_logs_seconds |
| 66 |
|
| 67 |
--let $second_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 68 |
FLUSH LOGS; |
| 69 |
|
| 70 |
# The sleep is in two parts to ensure a time gap between first_binlog_file |
| 71 |
# and second_binlog_file, by doing that we can check that one is purged and |
| 72 |
# another isn't. |
| 73 |
# sleep for n seconds here, n < $expire_logs_seconds |
| 74 |
--sleep 3 |
| 75 |
FLUSH LOGS; |
| 76 |
|
| 77 |
--error 1 |
| 78 |
--file_exists $MYSQLD_DATADIR/$first_binlog_file |
| 79 |
|
| 80 |
--file_exists $MYSQLD_DATADIR/$second_binlog_file |
| 81 |
|
| 82 |
RESET MASTER; |
| 83 |
--echo Testing with greater values of binlog_expire_logs_seconds |
| 84 |
|
| 85 |
SET GLOBAL binlog_expire_logs_seconds= 3600; |
| 86 |
SET GLOBAL expire_logs_days= 0; |
| 87 |
# This will test the expire period for three scenarios, described in the |
| 88 |
# .inc file. |
| 89 |
|
| 90 |
--source suite/binlog/include/binlog_expire_logs_seconds.inc |
| 91 |
|
| 92 |
--echo #### |
| 93 |
--echo #### 2.3: binlog_expire_logs_seconds == 0 and expire_logs_days > 0 |
| 94 |
--echo #### |
| 95 |
|
| 96 |
SET GLOBAL binlog_expire_logs_seconds= 0; |
| 97 |
SET GLOBAL expire_logs_days= 1; |
| 98 |
|
| 99 |
# This will test the expire period for three scenarios, described in the |
| 100 |
# .inc file. |
| 101 |
--source suite/binlog/include/binlog_expire_logs_seconds.inc |
| 102 |
|
| 103 |
# code coverage for WL#14930 boundary conditions |
| 104 |
# this will make the math output a negative purge |
| 105 |
# window, meaning that no purge can happen |
| 106 |
RESET MASTER; |
| 107 |
SET GLOBAL binlog_expire_logs_seconds=2147483648; |
| 108 |
--let $file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 109 |
FLUSH LOGS; |
| 110 |
--file_exists $MYSQLD_DATADIR/$file |
| 111 |
RESET MASTER; |
| 112 |
|
| 113 |
# code coverage for WL#14930 boundary conditions |
| 114 |
# computations should be correct even if binlog_expire_logs_seconds |
| 115 |
# is set to a very big value, effectively specifying that it should |
| 116 |
# delete binary logs that have a unix timestamp smaller than -2^31. |
| 117 |
# Before the bugfix, 32-bit platforms having time_t as 32-bit values |
| 118 |
# would internally wrap around the integers, which would make the |
| 119 |
# server purge files that are newer than what the user requested |
| 120 |
# to purge. |
| 121 |
|
| 122 |
SET GLOBAL binlog_expire_logs_seconds=4294967295; |
| 123 |
--let $file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 124 |
FLUSH LOGS; |
| 125 |
--file_exists $MYSQLD_DATADIR/$file |
| 126 |
RESET MASTER; |
| 127 |
|
| 128 |
--echo ### Code coverage for WL#14930 boundary conditions |
| 129 |
--echo ### Expiration time < 0 |
| 130 |
|
| 131 |
--echo ### Test case: binlog_expire_logs_seconds set to current time |
| 132 |
let $current_time=`SELECT UNIX_TIMESTAMP()`; |
| 133 |
--replace_result $current_time CURRENT_TIME |
| 134 |
--eval SET GLOBAL binlog_expire_logs_seconds= $current_time |
| 135 |
--let $file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 136 |
FLUSH LOGS; |
| 137 |
--file_exists $MYSQLD_DATADIR/$file |
| 138 |
RESET MASTER; |
| 139 |
|
| 140 |
--echo ### Test case: binlog_expire_logs_seconds set to current_time + 2^31 |
| 141 |
--replace_result $current_time CURRENT_TIME |
| 142 |
--eval SET GLOBAL binlog_expire_logs_seconds= 2<<31+ $current_time |
| 143 |
--let $file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 144 |
FLUSH LOGS; |
| 145 |
--file_exists $MYSQLD_DATADIR/$file |
| 146 |
RESET MASTER; |
| 147 |
|
| 148 |
--echo ### Test case: binlog_expire_logs_seconds set to current_time + 2^30 |
| 149 |
--replace_result $current_time CURRENT_TIME |
| 150 |
--eval SET GLOBAL binlog_expire_logs_seconds= 2<<30+ $current_time |
| 151 |
--let $file= query_get_value(SHOW MASTER STATUS, File, 1) |
| 152 |
FLUSH LOGS; |
| 153 |
--file_exists $MYSQLD_DATADIR/$file |
| 154 |
RESET MASTER; |
| 155 |
|
| 156 |
# reset the variables |
| 157 |
--eval SET GLOBAL binlog_expire_logs_seconds= $saved_binlog_expire_logs_seconds |
| 158 |
--eval SET GLOBAL expire_logs_days= $saved_expire_logs_days |