| 1 |
#### |
| 2 |
#### 1. When binlog_expire_logs_seconds == 0 and expire_logs_days == 0 |
| 3 |
#### no purge should happen |
| 4 |
SET GLOBAL binlog_expire_logs_seconds= 0; |
| 5 |
SET GLOBAL expire_logs_days= 0; |
| 6 |
CREATE TABLE t1(s LONGBLOB ); |
| 7 |
Case:0 |
| 8 |
FLUSH LOGS; |
| 9 |
INSERT INTO t1 VALUES('a'); |
| 10 |
FLUSH LOGS; |
| 11 |
#### 1. FLUSH LOGS |
| 12 |
FLUSH LOGS; |
| 13 |
RESET MASTER; |
| 14 |
Case:1 |
| 15 |
FLUSH LOGS; |
| 16 |
INSERT INTO t1 VALUES('a'); |
| 17 |
FLUSH LOGS; |
| 18 |
#### 2. Binlog_size > max_binlog_size |
| 19 |
SET @@GLOBAL.MAX_BINLOG_SIZE= 4096; |
| 20 |
INSERT INTO t1 (s) VALUES (REPEAT('s',50000)); |
| 21 |
RESET MASTER; |
| 22 |
Case:2 |
| 23 |
FLUSH LOGS; |
| 24 |
INSERT INTO t1 VALUES('a'); |
| 25 |
FLUSH LOGS; |
| 26 |
#### 3. Server restart |
| 27 |
# restart: --binlog_expire_logs_seconds=0 |
| 28 |
RESET MASTER; |
| 29 |
##### Cleanup ##### |
| 30 |
SET @@GLOBAL.MAX_BINLOG_SIZE= 1073741824;; |
| 31 |
DROP TABLE t1; |
| 32 |
RESET MASTER; |
| 33 |
#### |
| 34 |
#### 2.1: binlog_expire_logs_seconds > 0 and expire_logs_days > 0 |
| 35 |
#### expire_logs_days=1.5 and binlog_expire_logs_seconds=86400 |
| 36 |
#### Since binlog_expire_logs_seconds is set later |
| 37 |
#### expire_logs_days value will be overridden should be |
| 38 |
#### '0.000347222' |
| 39 |
#### |
| 40 |
Testing with smaller values of binlog_expire_logs_seconds |
| 41 |
SET GLOBAL expire_logs_days= 1.5; |
| 42 |
SET GLOBAL binlog_expire_logs_seconds= 30 ; |
| 43 |
SELECT @@expire_logs_days as 'Expected_0.000347222'; |
| 44 |
Expected_0.000347222 |
| 45 |
0.000347 |
| 46 |
SELECT @@binlog_expire_logs_seconds as Expected_30; |
| 47 |
Expected_30 |
| 48 |
30 |
| 49 |
FLUSH LOGS; |
| 50 |
FLUSH LOGS; |
| 51 |
FLUSH LOGS; |
| 52 |
RESET MASTER; |
| 53 |
#### |
| 54 |
#### 2.2: binlog_expire_logs_seconds = 43200 and expire_logs_days = 0 |
| 55 |
#### |
| 56 |
SET GLOBAL expire_logs_days=0; |
| 57 |
SET GLOBAL binlog_expire_logs_seconds=43200; |
| 58 |
SELECT @@expire_logs_days as 'Expected_0.5'; |
| 59 |
Expected_0.5 |
| 60 |
0.500000 |
| 61 |
SELECT @@binlog_expire_logs_seconds as Expected_43200; |
| 62 |
Expected_43200 |
| 63 |
43200 |
| 64 |
CREATE TABLE t1(s LONGBLOB ); |
| 65 |
Case:0 |
| 66 |
FLUSH LOGS; |
| 67 |
INSERT INTO t1 VALUES('a'); |
| 68 |
FLUSH LOGS; |
| 69 |
#### 1. FLUSH LOGS |
| 70 |
FLUSH LOGS; |
| 71 |
RESET MASTER; |
| 72 |
Case:1 |
| 73 |
FLUSH LOGS; |
| 74 |
INSERT INTO t1 VALUES('a'); |
| 75 |
FLUSH LOGS; |
| 76 |
#### 2. Binlog_size > max_binlog_size |
| 77 |
SET @@GLOBAL.MAX_BINLOG_SIZE= 4096; |
| 78 |
INSERT INTO t1 (s) VALUES (REPEAT('s',50000)); |
| 79 |
RESET MASTER; |
| 80 |
Case:2 |
| 81 |
FLUSH LOGS; |
| 82 |
INSERT INTO t1 VALUES('a'); |
| 83 |
FLUSH LOGS; |
| 84 |
#### 3. Server restart |
| 85 |
# restart: --binlog_expire_logs_seconds=43200 |
| 86 |
RESET MASTER; |
| 87 |
##### Cleanup ##### |
| 88 |
SET @@GLOBAL.MAX_BINLOG_SIZE= 1073741824;; |
| 89 |
DROP TABLE t1; |
| 90 |
RESET MASTER; |
| 91 |
#### |
| 92 |
#### 2.3: binlog_expire_logs_seconds == 0 and expire_logs_days > 0 |
| 93 |
#### |
| 94 |
SET GLOBAL binlog_expire_logs_seconds= 0; |
| 95 |
SET GLOBAL expire_logs_days= 1; |
| 96 |
SELECT @@expire_logs_days as Expected_1; |
| 97 |
Expected_1 |
| 98 |
1.000000 |
| 99 |
SELECT @@binlog_expire_logs_seconds as Expected_86400; |
| 100 |
Expected_86400 |
| 101 |
86400 |
| 102 |
CREATE TABLE t1(s LONGBLOB ); |
| 103 |
Case:0 |
| 104 |
FLUSH LOGS; |
| 105 |
INSERT INTO t1 VALUES('a'); |
| 106 |
FLUSH LOGS; |
| 107 |
#### 1. FLUSH LOGS |
| 108 |
FLUSH LOGS; |
| 109 |
RESET MASTER; |
| 110 |
Case:1 |
| 111 |
FLUSH LOGS; |
| 112 |
INSERT INTO t1 VALUES('a'); |
| 113 |
FLUSH LOGS; |
| 114 |
#### 2. Binlog_size > max_binlog_size |
| 115 |
SET @@GLOBAL.MAX_BINLOG_SIZE= 4096; |
| 116 |
INSERT INTO t1 (s) VALUES (REPEAT('s',50000)); |
| 117 |
RESET MASTER; |
| 118 |
Case:2 |
| 119 |
FLUSH LOGS; |
| 120 |
INSERT INTO t1 VALUES('a'); |
| 121 |
FLUSH LOGS; |
| 122 |
#### 3. Server restart |
| 123 |
# restart: --binlog_expire_logs_seconds=86400 |
| 124 |
RESET MASTER; |
| 125 |
##### Cleanup ##### |
| 126 |
SET @@GLOBAL.MAX_BINLOG_SIZE= 1073741824;; |
| 127 |
DROP TABLE t1; |
| 128 |
RESET MASTER; |
| 129 |
#### |
| 130 |
#### 2.4: binlog_expire_logs_seconds = 1 |
| 131 |
#### |
| 132 |
SET GLOBAL binlog_expire_logs_seconds= 1; |
| 133 |
SELECT @@expire_logs_days; |
| 134 |
@@expire_logs_days |
| 135 |
0.000012 |
| 136 |
SELECT @@binlog_expire_logs_seconds as Expected_1; |
| 137 |
Expected_1 |
| 138 |
1 |
| 139 |
#### |
| 140 |
#### 2.5. binlog_expire_logs_seconds = 8553600, testing max value 99days |
| 141 |
#### |
| 142 |
SET GLOBAL binlog_expire_logs_seconds= 8553600; |
| 143 |
SELECT @@expire_logs_days; |
| 144 |
@@expire_logs_days |
| 145 |
99.000000 |
| 146 |
SELECT @@binlog_expire_logs_seconds as Expected_8553600; |
| 147 |
Expected_8553600 |
| 148 |
8553600 |
| 149 |
SET GLOBAL binlog_expire_logs_seconds= 0; |
| 150 |
SET GLOBAL expire_logs_days= 0.000000; |