mariadb/mysql-test/suite/binlog_in_engine/binlog_flush_purge.result
Kristian Nielsen e1055af14f MDEV-34705: Binlog-in-engine: Implement file header page
Now the first page of each binlog tablespace file is reserved as a file
header, replacing the use of extra fields in the first gtid state record of
the file. The header is primarily used during recovery, especially to get
the file LSN before which no redo should be applied to the file.

Using a dedicated page makes it possible to durably sync the file header to
disk after RESET MASTER (and at first server startup) and not have it
overwritten (and potentially corrupted) later; this guarantees that the
recovery will have at least one file header to look at to determine from
which LSN to apply redo records.

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
2025-04-06 10:01:51 +02:00

167 lines
5.5 KiB
Text

RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(2048)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
BEGIN;
INSERT INTO t1 VALUES (2);
INSERT INTO t1 VALUES (3);
COMMIT;
INSERT INTO t2 VALUES (0, REPEAT("x", 2048));
INSERT INTO t2 SELECT a+1, b FROM t2;
INSERT INTO t2 SELECT a+2, b FROM t2;
INSERT INTO t2 SELECT a+4, b FROM t2;
INSERT INTO t2 SELECT a+8, b FROM t2;
SHOW BINARY LOGS;
Log_name File_size
binlog-000000.ibb 262144
binlog-000001.ibb 262144
FLUSH BINARY LOGS;
SHOW BINARY LOGS;
Log_name File_size
binlog-000000.ibb 40960
binlog-000001.ibb 262144
binlog-000002.ibb 262144
SET STATEMENT sql_log_bin=0 FOR
CALL mtr.add_suppression("InnoDB: Page corruption in binlog tablespace file page number 1");
FLUSH BINARY LOGS;
FLUSH BINARY LOGS;
SHOW BINLOG EVENTS IN 'binlog-000000.ibb' LIMIT 1;
ERROR HY000: Error when executing command SHOW BINLOG EVENTS: error reading event data
RESET MASTER;
SHOW BINARY LOGS;
Log_name File_size
binlog-000000.ibb 262144
binlog-000001.ibb 262144
INSERT INTO t1 VALUES (100);
INSERT INTO t2 VALUES (100, 'xyzzy');
DROP TABLE t1, t2;
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(2048)) ENGINE=InnoDB;
SET @old_min_slaves= @@GLOBAL.slave_connections_needed_for_purge;
SET GLOBAL slave_connections_needed_for_purge= 1;
PURGE BINARY LOGS TO 'binlog-000001.ibb';
ERROR HY000: A purgeable log is in use, will not purge
SHOW WARNINGS;
Level Code Message
Note 1375 Binary log 'binlog-000000.ibb' is not purged because less than 'slave_connections_needed_for_purge' slaves have processed it
Error 1378 A purgeable log is in use, will not purge
SET GLOBAL slave_connections_needed_for_purge= 0;
PURGE BINARY LOGS TO 'binlog-000001.ibb';
ERROR HY000: A purgeable log is in use, will not purge
SHOW WARNINGS;
Level Code Message
Note 1375 Binary log 'binlog-000000.ibb' is not purged because the binlog file is in active use
Error 1378 A purgeable log is in use, will not purge
SET @old_max_total= @@GLOBAL.max_binlog_total_size;
SET GLOBAL max_binlog_total_size= 4*@@GLOBAL.max_binlog_size;
SET SESSION binlog_format= ROW;
*** Do 1500 transactions ...
SHOW BINARY LOGS;
Log_name File_size
binlog-000011.ibb 262144
binlog-000012.ibb 262144
binlog-000013.ibb 262144
binlog-000014.ibb 262144
*** Test purge by date.
SET GLOBAL max_binlog_total_size= 0;
SET @old_expire= @@GLOBAL.binlog_expire_logs_seconds;
SET GLOBAL binlog_expire_logs_seconds= 1;
*** Do 187 inserts ...
SET GLOBAL binlog_expire_logs_seconds= 0;
*** Do 1000 transactions ...
SHOW BINARY LOGS;
Log_name File_size
binlog-000013.ibb 262144
binlog-000014.ibb 262144
binlog-000015.ibb 262144
binlog-000016.ibb 262144
binlog-000017.ibb 262144
binlog-000018.ibb 262144
binlog-000019.ibb 262144
binlog-000020.ibb 262144
binlog-000021.ibb 262144
binlog-000022.ibb 262144
binlog-000023.ibb 262144
binlog-000024.ibb 262144
SET @now= NOW();
*** Do 149 inserts ...
PURGE BINARY LOGS BEFORE @now;
SHOW BINARY LOGS;
Log_name File_size
binlog-000023.ibb 262144
binlog-000024.ibb 262144
binlog-000025.ibb 262144
*** Test PURGE BINARY LOGS TO
PURGE BINARY LOGS TO 'binlog-000025.ibb';
ERROR HY000: A purgeable log is in use, will not purge
SHOW WARNINGS;
Level Code Message
Note 1375 Binary log 'binlog-000024.ibb' is not purged because the binlog file is in active use
Error 1378 A purgeable log is in use, will not purge
SHOW BINARY LOGS;
Log_name File_size
binlog-000024.ibb 262144
binlog-000025.ibb 262144
*** Do 436 inserts ...
SHOW BINARY LOGS;
Log_name File_size
binlog-000024.ibb 262144
binlog-000025.ibb 262144
binlog-000026.ibb 262144
binlog-000027.ibb 262144
binlog-000028.ibb 262144
binlog-000029.ibb 262144
PURGE BINARY LOGS TO 'binlog-000025.ibb';
SHOW BINARY LOGS;
Log_name File_size
binlog-000025.ibb 262144
binlog-000026.ibb 262144
binlog-000027.ibb 262144
binlog-000028.ibb 262144
binlog-000029.ibb 262144
PURGE BINARY LOGS TO 'binlog-999999.ibb';
ERROR HY000: Target log not found in binlog index
SHOW WARNINGS;
Level Code Message
Error 1373 Target log not found in binlog index
*** Test purging logs when setting the maximum size.
SET GLOBAL max_binlog_total_size= ceil(1.5*@@GLOBAL.max_binlog_size);
Warnings:
Note 1375 Binary log 'binlog-000028.ibb' is not purged because the binlog file is in active use
SHOW BINARY LOGS;
Log_name File_size
binlog-000028.ibb 262144
binlog-000029.ibb 262144
SET SESSION binlog_format= MIXED;
DROP TABLE t1;
SET GLOBAL max_binlog_total_size= @old_max_total;
SET GLOBAL binlog_expire_logs_seconds= @old_expire;
*** Test FLUSH BINARY LOGS DELETE_DOMAIN_ID.
SET SESSION gtid_domain_id= 1;
SET SESSION gtid_seq_no= 1000;
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1, 0);
INSERT INTO t1 VALUES (2, 2), (3, 0), (4, 5), (5, 0), (6, 3), (7, 4), (8, 8);
SET SESSION gtid_domain_id= 2;
SET SESSION gtid_seq_no= 100;
ALTER TABLE t1 ADD INDEX b_idx(b);
SET SESSION gtid_domain_id= 1;
INSERT INTO t1 VALUES (10, 0), (11, 0), (12, 0);
SELECT @@GLOBAL.gtid_binlog_state;
@@GLOBAL.gtid_binlog_state
0-1-2508,1-1-1003,2-1-100
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(2);
ERROR HY000: Could not delete gtid domain. Reason: binlog files may contain gtids from the domain ('2') being deleted. Make sure to first purge those files.
SELECT @@GLOBAL.gtid_binlog_state;
@@GLOBAL.gtid_binlog_state
0-1-2508,1-1-1003,2-1-100
FLUSH BINARY LOGS;
PURGE BINARY LOGS TO 'binlog-000030.ibb';
FLUSH BINARY LOGS DELETE_DOMAIN_ID=(2);
SELECT @@GLOBAL.gtid_binlog_state;
@@GLOBAL.gtid_binlog_state
0-1-2508,1-1-1003
# restart
SELECT @@GLOBAL.gtid_binlog_state;
@@GLOBAL.gtid_binlog_state
0-1-2508,1-1-1003
DROP TABLE t1;