1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

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>
This commit is contained in:
Kristian Nielsen
2025-04-02 10:21:08 +02:00
parent 21751e21f1
commit e1055af14f
7 changed files with 406 additions and 196 deletions

View File

@@ -18,11 +18,11 @@ binlog-000001.ibb 262144
FLUSH BINARY LOGS;
SHOW BINARY LOGS;
Log_name File_size
binlog-000000.ibb 36864
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 0");
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;
@@ -83,7 +83,7 @@ binlog-000022.ibb 262144
binlog-000023.ibb 262144
binlog-000024.ibb 262144
SET @now= NOW();
*** Do 187 inserts ...
*** Do 149 inserts ...
PURGE BINARY LOGS BEFORE @now;
SHOW BINARY LOGS;
Log_name File_size

View File

@@ -27,22 +27,23 @@ FLUSH BINARY LOGS;
SHOW BINARY LOGS;
# Flush couple logs so we are sure the first file is on disk.
# Corrupt one bit in the first page of the first file to test that crc32
# Corrupt one bit in the first data page of the first file to test that crc32
# mismatch is caught.
SET STATEMENT sql_log_bin=0 FOR
CALL mtr.add_suppression("InnoDB: Page corruption in binlog tablespace file page number 0");
CALL mtr.add_suppression("InnoDB: Page corruption in binlog tablespace file page number 1");
FLUSH BINARY LOGS;
FLUSH BINARY LOGS;
--let $file= binlog-000000.ibb
--let $datadir= `SELECT @@datadir`
--let BINLOG_FILE= $datadir/$file
perl;
my $pos= 4096 + 50; # Early byte in page 1 (page 0 is file header).
open F, '+<', $ENV{BINLOG_FILE} or die $!;
sysseek F, 50, 0 or die $!;
sysseek F, $pos, 0 or die $!;
my $x;
sysread F, $x, 1 or die $!;
$x= chr(ord($x) ^ (1 <<3));
sysseek F, 50, 0 or die $!;
sysseek F, $pos, 0 or die $!;
syswrite F, $x, 1 or die $!;
EOF
@@ -146,7 +147,7 @@ SHOW BINARY LOGS;
--sleep 1
SET @now= NOW();
--sleep 1
--let $num_insert= `SELECT floor(256*1.5*1024/2100)`
--let $num_insert= `SELECT floor(256*1.2*1024/2100)`
--echo *** Do $num_insert inserts ...
--disable_query_log
BEGIN;

View File

@@ -57,6 +57,6 @@ EOF
--source include/wait_until_connected_again.inc
--let $binlog_file=
--let $binlog_start= 0
--let $binlog_start= 4
--source include/show_binlog_events.inc
DROP TABLE t1;