mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
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>
102 lines
5.0 KiB
Plaintext
102 lines
5.0 KiB
Plaintext
RESET MASTER;
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = ();
|
|
and the command execution is effective thence rotates binlog as usual
|
|
show binary logs;
|
|
Log_name File_size
|
|
master-bin.000001 #
|
|
master-bin.000002 #
|
|
Non-existed domain is warned, the command completes without rotation
|
|
but with a warning
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (99);
|
|
Warnings:
|
|
Warning 1076 The gtid domain being deleted ('99') is not in the current binlog state
|
|
show binary logs;
|
|
Log_name File_size
|
|
master-bin.000001 #
|
|
master-bin.000002 #
|
|
SET @@SESSION.gtid_domain_id=1;
|
|
SET @@SESSION.server_id=1;
|
|
CREATE TABLE t (a int);
|
|
SELECT @@GLOBAL.gtid_binlog_state, @@GLOBAL.gtid_binlog_pos;
|
|
@@GLOBAL.gtid_binlog_state @@GLOBAL.gtid_binlog_pos
|
|
1-1-1 1-1-1
|
|
include/show_binlog_events.inc
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000001 # Rotate # # master-bin.000002;pos=POS
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
|
|
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('1') being deleted. Make sure to first purge those files.
|
|
FLUSH BINARY LOGS;
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
|
|
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('1') being deleted. Make sure to first purge those files.
|
|
PURGE BINARY LOGS TO 'master-bin.000003';;
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
|
|
Gtid_list of the current binlog does not contain '1':
|
|
show binlog events in 'master-bin.000004' limit 1,1;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000004 # Gtid_list 1 # []
|
|
But the previous log's Gtid_list may have it which explains a warning from the following command
|
|
show binlog events in 'master-bin.000003' limit 1,1;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000003 # Gtid_list 1 # [1-1-1]
|
|
Already deleted domain in Gtid_list of the earliest log is benign
|
|
but may cause a warning
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
|
|
Warnings:
|
|
Warning 1076 The current gtid binlog state is incompatible with a former one missing gtids from the '1-1' domain-server pair which is referred to in the gtid list describing an earlier state. Ignore if the domain ('1') was already explicitly deleted.
|
|
Warning 1076 The gtid domain being deleted ('1') is not in the current binlog state
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0);
|
|
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('1') being deleted. Make sure to first purge those files.
|
|
MDEV-31140: Missing error from DELETE_DOMAIN_ID when gtid_binlog_state partially matches GTID_LIST.
|
|
FLUSH BINARY LOGS;
|
|
PURGE BINARY LOGS TO 'master-bin.000005';
|
|
show binary logs;
|
|
Log_name File_size
|
|
master-bin.000005 #
|
|
SET @@SESSION.gtid_domain_id=8;
|
|
SET @@SESSION.server_id=10*8 + 1;
|
|
INSERT INTO t SELECT 1+MAX(a) FROM t;
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0);
|
|
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('8') being deleted. Make sure to first purge those files.
|
|
FLUSH BINARY LOGS;
|
|
PURGE BINARY LOGS TO 'master-bin.000006';
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0);
|
|
Warnings:
|
|
Warning 1076 The gtid domain being deleted ('0') is not in the current binlog state
|
|
Gtid_list of the current binlog does not contain 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 0:
|
|
show binlog events in 'master-bin.000007' limit 1,1;
|
|
Log_name Pos Event_type Server_id End_log_pos Info
|
|
master-bin.000007 # Gtid_list 1 # []
|
|
SET @@SESSION.gtid_domain_id=1;;
|
|
SET @@SESSION.server_id=1;
|
|
SET @@SESSION.gtid_seq_no=1;
|
|
INSERT INTO t SET a=1;
|
|
SET @@SESSION.server_id=2;
|
|
SET @@SESSION.gtid_seq_no=2;
|
|
INSERT INTO t SET a=2;
|
|
SET @@SESSION.gtid_domain_id=11;
|
|
SET @@SESSION.server_id=11;
|
|
SET @@SESSION.gtid_seq_no=11;
|
|
INSERT INTO t SET a=11;
|
|
SET @gtid_binlog_state_saved=@@GLOBAL.gtid_binlog_state;
|
|
FLUSH BINARY LOGS;
|
|
SET @@SESSION.gtid_domain_id=11;
|
|
SET @@SESSION.server_id=11;
|
|
SET @@SESSION.gtid_seq_no=1;
|
|
INSERT INTO t SET a=1;
|
|
SELECT @gtid_binlog_state_saved "as original state", @@GLOBAL.gtid_binlog_state as "out of order for 11 domain state";
|
|
as original state out of order for 11 domain state
|
|
1-1-1,1-2-2,11-11-11 1-1-1,1-2-2,11-11-1
|
|
PURGE BINARY LOGS TO 'master-bin.000008';
|
|
the following command succeeds with warnings
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (1);
|
|
Warnings:
|
|
Warning 1076 The current gtid binlog state is incompatible with a former one having a gtid '11-11-1' which is less than the '11-11-11' of the gtid list describing an earlier state. The state may have been affected by manually injecting a lower sequence number gtid or via replication.
|
|
RESET MASTER;
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (4294967296);
|
|
ERROR HY000: The value of gtid domain being deleted ('4294967296') exceeds its maximum size of 32 bit unsigned integer
|
|
FLUSH BINARY LOGS DELETE_DOMAIN_ID = (4294967295);
|
|
Warnings:
|
|
Warning 1076 The gtid domain being deleted ('4294967295') is not in the current binlog state
|
|
DROP TABLE t;
|
|
RESET MASTER;
|