Debian Codegraph @

mysql-test/suite/rpl/t/rpl_lock_backup_binary_and_relay_logs.test

raw
1 # ==== Purpose ====
2 #
3 # This test case will test binary log expire, purge binary logs and automatic
4 # relay log purge wrt backup lock.
5 #
6 # According to backup lock specification:
7 # - No files must be created, renamed, or removed (exception: new binary log
8 # files can be created);
9 #
10 # There are no exceptions with respect to removal of binary log files.
11 #
12 # There is no mention about exceptions for relay log files. Relay log files
13 # shall be handled with same exceptions of binary log files.
14 #
15 # Any automatic purge or binary and relay log files should be avoided
16 # while the server instance is locked for backup.
17 #
18 # ==== Related Bugs and Worklogs ====
19 #
20 # BUG#27030339: BACKUP_LOCK IS ALLOWING REMOVAL OF BINARY AND RELAY LOG FILES
21 #
22
23 # This test case is binary log format agnostic
24 --source include/have_binlog_format_mixed.inc
25 --source include/master-slave.inc
26
27 # BUG#28196680 Suppress warnings thrown when trying to purge logs which
28 # are still being read by a thread
29 --disable_query_log
30 CALL mtr.add_suppression("\\[Warning\\] .* was not purged because it was being "
31 "read by thread");
32 CALL mtr.add_suppression("Could not purge binary logs since another session is executing LOCK INSTANCE FOR BACKUP. Wait for that session to release the lock.");
33 --enable_query_log
34
35 CREATE TABLE t1 (c1 INT);
36 --source include/sync_slave_sql_with_master.inc
37 --source include/rpl_connection_master.inc
38
39 # Save global variables to be changed during the test case
40 SET @saved_expire_logs_days= @@GLOBAL.expire_logs_days;
41 SET @saved_binlog_expire_logs_seconds= @@GLOBAL.binlog_expire_logs_seconds;
42
43 SET @@GLOBAL.expire_logs_days= 0;
44 SET @@GLOBAL.binlog_expire_logs_seconds= 1;
45
46 # Prevent removal of files (among other restrictions)
47 --source include/rpl_connection_master1.inc
48 LOCK INSTANCE FOR BACKUP;
49 --source include/rpl_connection_slave.inc
50 LOCK INSTANCE FOR BACKUP;
51 --let $s1= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
52
53 # Generate workload on master
54 --source include/rpl_connection_master.inc
55 --let $m1= query_get_value(SHOW MASTER STATUS, File, 1)
56 FLUSH LOCAL LOGS;
57
58 --let $m2= query_get_value(SHOW MASTER STATUS, File, 1)
59 INSERT INTO t1 VALUES (1);
60 INSERT INTO t1 VALUES (2);
61 INSERT INTO t1 VALUES (3);
62 FLUSH LOCAL LOGS;
63
64 --let $m3= query_get_value(SHOW MASTER STATUS, File, 1)
65 INSERT INTO t1 VALUES (4);
66 INSERT INTO t1 VALUES (5);
67 INSERT INTO t1 VALUES (6);
68 FLUSH LOCAL LOGS;
69 INSERT INTO t1 VALUES (7);
70
71 # Ensure slave has consumed first three binary log files
72 --source include/sync_slave_sql_with_master.inc
73 --let $sN= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1)
74
75 --source include/rpl_connection_master.inc
76 # Take a nap to allow binary log expiration to take action
77 --sleep 4
78 FLUSH LOCAL LOGS;
79 INSERT INTO t1 VALUES (8);
80
81 --source include/sync_slave_sql_with_master.inc
82 # Check that relay log files are still around
83 --disable_result_log
84 --replace_result $s1 FIRST_RELAY_LOG_FILE
85 --eval SHOW RELAYLOG EVENTS IN '$s1'
86 --replace_result $sN LAST_RELAY_LOG_FILE
87 --eval SHOW RELAYLOG EVENTS IN '$sn'
88 --enable_result_log
89
90 --source include/rpl_connection_master.inc
91 # Check that binary log files are still around
92 --let $assert_text= 1st binary log file should still be available
93 --let $assert_cond= "[SHOW BINARY LOGS, Log_name, 1]" = "$m1"
94 --source include/assert.inc
95 --let $assert_text= 2nd binary log file should still be available
96 --let $assert_cond= "[SHOW BINARY LOGS, Log_name, 2]" = "$m2"
97 --source include/assert.inc
98 --let $assert_text= 3rd binary log file should still be available
99 --let $assert_cond= "[SHOW BINARY LOGS, Log_name, 3]" = "$m3"
100 --source include/assert.inc
101
102 # Assume backup as taken at this point
103 --source include/rpl_connection_slave.inc
104 UNLOCK INSTANCE;
105 --source include/rpl_connection_master1.inc
106 UNLOCK INSTANCE;
107 FLUSH LOCAL LOGS;
108
109 # Expired binary log files should not be available
110 --let $assert_text= 1st to 3rd binary log file should be not available
111 --let $assert_cond= "[SHOW BINARY LOGS, Log_name, 1]" <> "$m1" AND "<1>" <> "$m2" AND "<1>" <> "$m3"
112 --source include/assert.inc
113
114 DROP TABLE t1;
115 # Unused relay log files should not be available
116 --source include/sync_slave_sql_with_master.inc
117 --disable_result_log
118 --replace_result $s1 FIRST_RELAY_LOG_FILE
119 --error ER_ERROR_WHEN_EXECUTING_COMMAND
120 --eval SHOW RELAYLOG EVENTS IN '$s1'
121 --replace_result $sN LAST_RELAY_LOG_FILE
122 --error ER_ERROR_WHEN_EXECUTING_COMMAND
123 --eval SHOW RELAYLOG EVENTS IN '$sn'
124 --enable_result_log
125
126 # Cleanup
127 --source include/rpl_connection_master.inc
128
129 # Restore changed global variables
130 SET @@GLOBAL.binlog_expire_logs_seconds= @saved_binlog_expire_logs_seconds;
131 SET @@GLOBAL.expire_logs_days= @saved_expire_logs_days;
132
133 --source include/rpl_end.inc