Skip to content

Commit dd99780

Browse files
committed
MDEV-34504 PURGE BINARY LOGS not working anymore
PURGE BINARY LOGS did not always purge binary logs. This commit fixes some of the issues and adds notifications if a binary log cannot be purged. User visible changes: - 'PURGE BINARY LOG TO log_name' and 'PURGE BINARY LOGS BEFORE date' worked differently. 'TO' ignored 'slave_connections_needed_for_purge' while 'BEFORE' did not. Now both versions ignores the 'slave_connections_needed_for_purge variable'. - 'PURGE BINARY LOG..' commands now returns 'note' if a binary log cannot be deleted like Note 1375 Binary log 'master-bin.000004' is not purged because it is the current active binlog - Automatic binary log purges, based on date or size, will write a note to the error log if a binary log matching the size or date cannot yet be deleted. - If 'slave_connections_needed_for_purge' is set from a config or command line, it is set to 0 if Galera is enabled and 1 otherwise (old default). This ensures that automatic binary log purge works with Galera as before the addition of 'slave_connections_needed_for_purge'. If the variable is changed to 0, a warning will be printed to the error log. Code changes: - Added THD argument to several purge_logs related functions that needed THD. - Added 'interactive' options to purge_logs functions. This allowed me to remove testing of sql_command == SQLCOM_PURGE. - Changed purge_logs_before_date() to first check if log is applicable before calling can_purge_logs(). This ensures we do not get a notification for logs that does not match the remove criteria. - MYSQL_BIN_LOG::can_purge_log() will write notifications to the user or error log if a log cannot yet be removed. - log_in_use() will return reason why a binary log cannot be removed. Changes to keep code consistent: - Moved checking of binlog_format for Galera to be after Galera is initialized (The old check never worked). If Galera is enabled we now change the binlog_format to ROW, with a warning, instead of aborting the server. If this change happens a warning will be printed to the error log. - Print a warning if Galera or FLASHBACK changes the binlog_format to ROW. Before it was done silently. Reviewed by: Sergei Golubchik <serg@mariadb.com>, Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent 5fb07d9 commit dd99780

24 files changed

+269
-54
lines changed

mysql-test/include/wait_for_purge.inc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@
2020
#
2121
# SIDE EFFECTS:
2222
#
23-
# Disables --query_log while running, enables it afterwards.
23+
# Disables --query_log and warnings while running, enables them afterwards.
2424

2525
--echo include/wait_for_purge.inc "$purge_binlogs_to"
2626

2727
let $_wait_count= 300;
2828
let $_done= 0;
2929

3030
--disable_query_log
31+
--disable_warnings
32+
3133
while ($_wait_count)
3234
{
3335
dec $_wait_count;
@@ -50,4 +52,5 @@ if (!$_done)
5052
eval SHOW BINARY LOGS;
5153
--die ERROR: failed while waiting for binlog purge to $purge_binlogs_to
5254
}
55+
--enable_warnings
5356
--enable_query_log

mysql-test/main/mysqld--help.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,7 @@ The following specify which files/extra groups are read (specified before remain
13081308
Minimum number of connected slaves required for automatic
13091309
binary log purge with max_binlog_total_size,
13101310
binlog_expire_logs_seconds or binlog_expire_logs_days.
1311+
Default is 0 when Galera is enabled and 1 otherwise.
13111312
--slave-ddl-exec-mode=name
13121313
How replication events should be executed. Legal values
13131314
are STRICT and IDEMPOTENT (default). In IDEMPOTENT mode,

mysql-test/suite/binlog/r/binlog_flush_binlogs_delete_domain.result

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtid
4949
MDEV-31140: Missing error from DELETE_DOMAIN_ID when gtid_binlog_state partially matches GTID_LIST.
5050
FLUSH BINARY LOGS;
5151
PURGE BINARY LOGS TO 'master-bin.000005';
52+
show binary logs;
53+
Log_name File_size
54+
master-bin.000005 #
5255
SET @@SESSION.gtid_domain_id=8;
5356
SET @@SESSION.server_id=10*8 + 1;
5457
INSERT INTO t SELECT 1+MAX(a) FROM t;

mysql-test/suite/binlog/r/binlog_index.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ flush logs;
3030
flush logs;
3131
*** must be a warning master-bin.000001 was not found ***
3232
Warnings:
33+
Note 1375 Binary log 'master-bin.000004' is not purged because it is the current active binlog
3334
Warning 1612 Being purged log master-bin.000001 was not found
3435
*** must show one record, of the active binlog, left in the index file after PURGE ***
3536
show binary logs;

mysql-test/suite/binlog/r/binlog_xa_recover.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ master-bin.000006 # Format_desc # # SERVER_VERSION, BINLOG_VERSION
8989
master-bin.000006 # Gtid_list # # [#-#-#]
9090
master-bin.000006 # Binlog_checkpoint # # master-bin.000004
9191
PURGE BINARY LOGS TO "master-bin.000006";
92+
Warnings:
93+
Note 1375 Binary log 'master-bin.000004' is not purged because it may be needed for crash recovery (XID)
9294
show binary logs;
9395
Log_name File_size
9496
master-bin.000004 #

mysql-test/suite/binlog/t/binlog_flush_binlogs_delete_domain.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ while ($domain_cnt)
9191
FLUSH BINARY LOGS;
9292
--let $purge_to_binlog= query_get_value(SHOW MASTER STATUS, File, 1)
9393
--eval PURGE BINARY LOGS TO '$purge_to_binlog'
94+
--source include/show_binary_logs.inc
9495
--eval SET @@SESSION.gtid_domain_id=$err_domain_id
9596
--eval SET @@SESSION.server_id=10*$err_domain_id + $err_server_id
9697
eval INSERT INTO t SELECT 1+MAX(a) FROM t;

mysql-test/suite/binlog_encryption/binlog_index.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ flush logs;
3030
flush logs;
3131
*** must be a warning master-bin.000001 was not found ***
3232
Warnings:
33+
Note 1375 Binary log 'master-bin.000004' is not purged because it is the current active binlog
3334
Warning 1612 Being purged log master-bin.000001 was not found
3435
*** must show one record, of the active binlog, left in the index file after PURGE ***
3536
show binary logs;

mysql-test/suite/binlog_encryption/binlog_xa_recover.result

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ master-bin.000006 # Start_encryption # #
9393
master-bin.000006 # Gtid_list # # [#-#-#]
9494
master-bin.000006 # Binlog_checkpoint # # master-bin.000004
9595
PURGE BINARY LOGS TO "master-bin.000006";
96+
Warnings:
97+
Note 1375 Binary log 'master-bin.000004' is not purged because it may be needed for crash recovery (XID)
9698
show binary logs;
9799
Log_name File_size
98100
master-bin.000004 #

mysql-test/suite/compat/oracle/r/binlog_ptr_mysqlbinlog.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
call mtr.add_suppression("Binlog_format changed to.*flashback");
12
SET @@SQL_MODE = 'ORACLE';
23
##########################################################################
34
# Test verifies Gtid_log_event/Xid_log_event specific print #

mysql-test/suite/compat/oracle/t/binlog_ptr_mysqlbinlog.test

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
--source include/have_log_bin.inc
1919
--source include/have_innodb.inc
2020

21+
call mtr.add_suppression("Binlog_format changed to.*flashback");
22+
2123
let $MYSQLD_DATADIR= `select @@datadir`;
2224
SET @@SQL_MODE = 'ORACLE';
2325

0 commit comments

Comments
 (0)