File: binlog_expire_logs_seconds.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 (158 lines) | stat: -rw-r--r-- 5,480 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
157
158
#
# WL#9236: Add a new variable binlog_expire_logs_seconds
#
# ==== Purpose ====
# The test case test the following:
#
# 1. If binlog_expire_logs_seconds == 0 and expire_logs_days == 0, no purge 
#    happens.
#
# 2. In all the below listed cases it puges the binary logs older than the
#    timeout and keeps the binary logs newer than the timeout.
#
#    2.1. binlog_expire_logs_seconds > 0 and expire_logs_days > 0
#    2.2. binlog_expire_logs_seconds > 0 and expire_logs_days == 0
#    2.3. binlog_expire_logs_seconds == 0 and expire_logs_days > 0
#
# Additional tests for the boundaries of expire_logs_days already
# exist on the sys_vars.expire_logs_days_basic test case.
#
# === References ===
#
# Bug#33670457: Incorrect result when `binlog_expire_logs_seconds` has maximum
#               value in 32 bit
#

# Test in this file is binlog format agnostic, thus no need
# to rerun it for every format.
CALL mtr.add_suppression("The option expire_logs_days cannot be used together*");
--source include/have_binlog_format_row.inc
--source include/not_windows.inc
--source include/not_binlog_transaction_compression_on.inc

--let $saved_expire_logs_days= `SELECT @@GLOBAL.expire_logs_days`
--let $saved_binlog_expire_logs_seconds= `SELECT @@GLOBAL.binlog_expire_logs_seconds`
# Set the datadir
--let $MYSQLD_DATADIR= `SELECT @@datadir`

--echo ####
--echo #### 1. When binlog_expire_logs_seconds == 0 and expire_logs_days == 0
--echo ####    no purge should happen

SET GLOBAL binlog_expire_logs_seconds= 0;
SET GLOBAL expire_logs_days= 0;

# This will test the expire period for three scenarios, described in the 
# .inc file.
--source suite/binlog/include/binlog_expire_logs_seconds.inc

--echo ####
--echo #### 2.1: binlog_expire_logs_seconds > 0 and expire_logs_days == 0
--echo ####
 
# Here we will test both with smaller values and larger values

--echo Testing with smaller values of binlog_expire_logs_seconds

SET GLOBAL binlog_expire_logs_seconds= 30;
SET GLOBAL expire_logs_days= 0;

--let $expire_logs_seconds= `SELECT @@global.binlog_expire_logs_seconds + @@global.expire_logs_days * 24 * 60 * 60`

--let $first_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
FLUSH LOGS;

--sleep $expire_logs_seconds

--let $second_binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
FLUSH LOGS;

# The sleep is in two parts to ensure a time gap between first_binlog_file
# and second_binlog_file, by doing that we can check that one is purged and
# another isn't.
# sleep for n seconds here, n < $expire_logs_seconds
--sleep 3
FLUSH LOGS;

--error 1
--file_exists $MYSQLD_DATADIR/$first_binlog_file

--file_exists $MYSQLD_DATADIR/$second_binlog_file

RESET MASTER;
--echo Testing with greater values of binlog_expire_logs_seconds

SET GLOBAL binlog_expire_logs_seconds= 3600;
SET GLOBAL expire_logs_days= 0;
# This will test the expire period for three scenarios, described in the 
# .inc file.

--source suite/binlog/include/binlog_expire_logs_seconds.inc

--echo ####
--echo #### 2.3: binlog_expire_logs_seconds == 0 and expire_logs_days > 0
--echo ####

SET GLOBAL binlog_expire_logs_seconds= 0;
SET GLOBAL expire_logs_days= 1;

# This will test the expire period for three scenarios, described in the 
# .inc file.
--source suite/binlog/include/binlog_expire_logs_seconds.inc

# code coverage for WL#14930 boundary conditions
# this will make the math output a negative purge
# window, meaning that no purge can happen
RESET MASTER;
SET GLOBAL binlog_expire_logs_seconds=2147483648;
--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
FLUSH LOGS;
--file_exists $MYSQLD_DATADIR/$file
RESET MASTER;

# code coverage for WL#14930 boundary conditions
# computations should be correct even if binlog_expire_logs_seconds 
# is set to a very big value, effectively specifying that it should 
# delete binary logs that have a unix timestamp smaller than -2^31. 
# Before the bugfix, 32-bit platforms having time_t as 32-bit values 
# would internally wrap around the integers, which would make the 
# server purge files that are newer than what the user requested 
# to purge.

SET GLOBAL binlog_expire_logs_seconds=4294967295;
--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
FLUSH LOGS;
--file_exists $MYSQLD_DATADIR/$file
RESET MASTER;

--echo ### Code coverage for WL#14930 boundary conditions
--echo ### Expiration time < 0

--echo ### Test case: binlog_expire_logs_seconds set to current time
let $current_time=`SELECT UNIX_TIMESTAMP()`;
--replace_result $current_time CURRENT_TIME
--eval SET GLOBAL binlog_expire_logs_seconds= $current_time
--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
FLUSH LOGS;
--file_exists $MYSQLD_DATADIR/$file
RESET MASTER;

--echo ### Test case: binlog_expire_logs_seconds set to current_time + 2^31
--replace_result $current_time CURRENT_TIME
--eval SET GLOBAL binlog_expire_logs_seconds=  2<<31+ $current_time
--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
FLUSH LOGS;
--file_exists $MYSQLD_DATADIR/$file
RESET MASTER;

--echo ### Test case: binlog_expire_logs_seconds set to current_time + 2^30
--replace_result $current_time CURRENT_TIME
--eval SET GLOBAL binlog_expire_logs_seconds=  2<<30+ $current_time
--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
FLUSH LOGS;
--file_exists $MYSQLD_DATADIR/$file
RESET MASTER;

# reset the variables
--eval SET GLOBAL binlog_expire_logs_seconds= $saved_binlog_expire_logs_seconds
--eval SET GLOBAL expire_logs_days= $saved_expire_logs_days