Debian Codegraph @

mysql-test/suite/binlog_gtid/t/binlog_gtid_purge_binlog_at_startup.test

raw
1 # ==== Purpose ====
2 #
3 # The purpose of this test is to ensure that GTID_PURGED variable is
4 # properly set when binlogs need to be purged by means of
5 # `binlog_expire_logs_seconds` usage during server startup process.
6 #
7 # ==== Requirements ====
8 #
9 # R1. When `binlog_expire_logs_seconds` has been expired upon server
10 # restart, binary logs should be pureged and GTID_PURGED should be updated
11 # accordingly.
12 #
13 # ==== Implementation ====
14 #
15 # TC1. Restart the server with `binlog_expire_logs_seconds=1`
16 # -----------------------------------------------------------
17 # 1. Create a table.
18 # 2. Stop the server.
19 # 3. Sleep for the same amount of seconds we'll use in
20 # `--binlog-expire-logs-seconds`.
21 # 4. Start the server with `--binlog-expire-logs-seconds`.
22 # 5. Ensure GTID_PURGED is set at the correct value.
23 # 6. Ensure that we have only one binary log file.
24 #
25 # TC2. Restart the server with `binlog_expire_logs_seconds` and after flush
26 # -------------------------------------------------------------------------
27 # 1. Create a table.
28 # 2. Flush the logs.
29 # 3. Insert a row.
30 # 4. Stop the server.
31 # 5. Sleep for the same amount of seconds we'll use in
32 # `--binlog-expire-logs-seconds`.
33 # 6. Start the server with `--binlog-expire-logs-seconds`.
34 # 7. Ensure GTID_PURGED is set at the correct value.
35 # 8. Ensure that we have only one binary log file.
36 #
37 # ==== References ====
38 #
39 # BUG#32008512 ASSERTION `LOST_GTIDS->IS_EMPTY()' FAILED WHEN MYSQLD
40 # STARTED
41 # BUG#32134875 PURGE BINLOG IN INSTANCE STARTUP CAUSE PREVIOUS_GTIDS WRONG
42 # IN NEW BINLOG FILE
43 #
44 --source include/have_binlog_format_row.inc
45 --source include/have_debug.inc
46
47 --let $saved_expire_seconds = `SELECT @@binlog_expire_logs_seconds`
48
49 # TC1. Restart the server with `binlog_expire_logs_seconds=1`
50 # -----------------------------------------------------------
51 --let $expire_seconds = 1
52 RESET MASTER;
53 # 1. Create a table.
54 CREATE TABLE t (a INT);
55
56 # 2. Stop the server.
57 --source include/stop_mysqld.inc
58 # 3. Sleep for the same amount of seconds we'll use in
59 # `--binlog-expire-logs-seconds`.
60 --sleep $expire_seconds
61 # 4. Start the server with `--binlog-expire-logs-seconds`.
62 --let $restart_parameters = restart: --binlog-expire-logs-seconds=$expire_seconds
63 --source include/start_mysqld.inc
64
65 --let $server_uuid = `SELECT @@server_uuid`
66
67 # 5. Ensure GTID_PURGED is set at the correct value.
68 --let $assert_text = GTID_PURGED is consistent
69 --let $assert_cond = "[SELECT @@gtid_purged]" = "$server_uuid:1"
70 --source include/assert.inc
71
72 # 6. Ensure that we have only one binary log file.
73 --let $statement = SHOW BINARY LOGS
74 --let $column = Log_name
75 --source include/get_row_count.inc
76 --let $assert_text = We have 1 binlog file
77 --let $assert_cond = $row_count = 1
78 --source include/assert.inc
79
80 DROP TABLE t;
81
82 #
83 # TC2. Restart the server with `binlog_expire_logs_seconds` and after flush
84 # -------------------------------------------------------------------------
85 --let $expire_seconds = 5
86 RESET MASTER;
87 # 1. Create a table.
88 CREATE TABLE t (a INT);
89 # 2. Flush the logs.
90 FLUSH LOGS;
91 # 3. Insert a row
92 INSERT INTO t VALUES (1), (2), (3);
93
94 # 4. Stop the server.
95 --source include/stop_mysqld.inc
96 # 5. Sleep for the same amount of seconds we'll use in
97 # `--binlog-expire-logs-seconds`.
98 --sleep $expire_seconds
99 # 6. Start the server with `--binlog-expire-logs-seconds`.
100 --let $restart_parameters = restart: --binlog-expire-logs-seconds=$expire_seconds
101 --source include/start_mysqld.inc
102
103 --let $server_uuid = `SELECT @@server_uuid`
104
105 # 7. Ensure GTID_PURGED is set at the correct value.
106 --let $assert_text = GTID_PURGED is consistent
107 --let $assert_cond = "[SELECT @@gtid_purged]" = "$server_uuid:1-2"
108 --source include/assert.inc
109
110 # 8. Ensure that we have only one binary log file.
111 --let $statement = SHOW BINARY LOGS
112 --let $column = Log_name
113 --source include/get_row_count.inc
114 --let $assert_text = We have 1 binlog file
115 --let $assert_cond = $row_count = 1
116 --source include/assert.inc
117
118 DROP TABLE t;
119 --replace_result $saved_expire_seconds SAVED_EXPIRE_SECONDS
120 --eval SET GLOBAL binlog_expire_logs_seconds = $saved_expire_seconds