mirror of
https://github.com/MariaDB/server.git
synced 2025-04-18 21:44:20 +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>
120 lines
4.0 KiB
Plaintext
120 lines
4.0 KiB
Plaintext
# ==== Purpose ====
|
|
#
|
|
# Test verifies that point in time recovery of binary log works when
|
|
# sql_mode='ORACLE'.
|
|
#
|
|
# BEGIN statement is printed in three places
|
|
# 1) "Gtid_log_event::print"
|
|
# 2) "Xid_log_event::print" if flashback is enabled
|
|
# 3) "Query_log_event::print" if flashback is enabled and engine is
|
|
# non-transacional.
|
|
#
|
|
# Test verifies all these cases.
|
|
#
|
|
# ==== References ====
|
|
#
|
|
# MDEV-23108: Point in time recovery of binary log fails when sql_mode=ORACLE
|
|
#
|
|
--source include/have_log_bin.inc
|
|
--source include/have_innodb.inc
|
|
|
|
call mtr.add_suppression("Binlog_format changed to.*flashback");
|
|
|
|
let $MYSQLD_DATADIR= `select @@datadir`;
|
|
SET @@SQL_MODE = 'ORACLE';
|
|
|
|
--echo ##########################################################################
|
|
--echo # Test verifies Gtid_log_event/Xid_log_event specific print #
|
|
--echo ##########################################################################
|
|
CREATE TABLE tm (f INT) ENGINE=MYISAM;
|
|
INSERT INTO tm VALUES (10);
|
|
|
|
CREATE TABLE t(f INT) ENGINE=INNODB;
|
|
INSERT INTO t VALUES (10);
|
|
|
|
DELIMITER /;
|
|
CREATE OR REPLACE PROCEDURE simpleproc (param1 OUT INT) AS
|
|
BEGIN
|
|
SELECT COUNT(*) INTO param1 FROM t;
|
|
END;
|
|
/
|
|
CREATE FUNCTION f1 RETURN INT
|
|
AS
|
|
BEGIN
|
|
RETURN 10;
|
|
END;
|
|
/
|
|
DELIMITER ;/
|
|
|
|
FLUSH LOGS;
|
|
--echo ##########################################################################
|
|
--echo # Delete data from master so that it can be restored from binlog #
|
|
--echo ##########################################################################
|
|
DROP FUNCTION f1;
|
|
DROP PROCEDURE simpleproc;
|
|
DROP TABLE tm;
|
|
DROP TABLE t;
|
|
|
|
--exec $MYSQL_BINLOG $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/test.sql
|
|
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/test.sql
|
|
|
|
--echo ##########################################################################
|
|
--echo # Post recovery using mysqlbinlog #
|
|
--echo ##########################################################################
|
|
SHOW TABLES;
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
--horizontal_results
|
|
SELECT f1();
|
|
CALL simpleproc(@a);
|
|
SELECT @a;
|
|
|
|
--echo "***** Clean Up *****"
|
|
DROP TABLE t,tm;
|
|
DROP PROCEDURE simpleproc;
|
|
DROP FUNCTION f1;
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/test.sql
|
|
RESET MASTER;
|
|
|
|
--echo ##########################################################################
|
|
--echo # Test verifies Gtid_log_event/Xid_log_event/Qery_log_event #
|
|
--echo # specific print along with flashback option #
|
|
--echo ##########################################################################
|
|
CREATE TABLE tm(f INT) ENGINE=MYISAM;
|
|
INSERT INTO tm VALUES (10);
|
|
INSERT INTO tm VALUES (20);
|
|
CREATE TABLE t(f INT) ENGINE=INNODB;
|
|
INSERT INTO t VALUES (10);
|
|
INSERT INTO t VALUES (20);
|
|
--echo ##########################################################################
|
|
--echo # Initial data #
|
|
--echo ##########################################################################
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
FLUSH LOGS;
|
|
DELETE FROM tm WHERE f=20;
|
|
DELETE FROM t WHERE f=20;
|
|
FLUSH LOGS;
|
|
|
|
--echo ##########################################################################
|
|
--echo # Data after deletion #
|
|
--echo ##########################################################################
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
--exec $MYSQL_BINLOG --flashback $MYSQLD_DATADIR/master-bin.000002 > $MYSQLTEST_VARDIR/tmp/test.sql
|
|
|
|
--let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/test.sql
|
|
--let SEARCH_PATTERN=START TRANSACTION
|
|
--source include/search_pattern_in_file.inc
|
|
--exec $MYSQL < $MYSQLTEST_VARDIR/tmp/test.sql
|
|
|
|
--echo ##########################################################################
|
|
--echo # Data after recovery using flashback #
|
|
--echo ##########################################################################
|
|
SELECT * FROM tm;
|
|
SELECT * FROM t;
|
|
|
|
--echo "***** Clean Up *****"
|
|
DROP TABLE t,tm;
|
|
--remove_file $MYSQLTEST_VARDIR/tmp/test.sql
|