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

MDEV-34705: Binlog-in-engine: Recovery testcase + few bugfixes

Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
This commit is contained in:
Kristian Nielsen
2025-03-19 16:37:55 +01:00
parent b3c6bbdbd3
commit 4cdb059b8c
6 changed files with 187 additions and 11 deletions

View File

@@ -8,7 +8,6 @@
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
--let $gtid_pos= `SELECT @@last_gtid`
INSERT INTO t1 VALUES (1);
--let $no_checkpoint_flush= 1

View File

@@ -0,0 +1 @@
--loose-skip-stack-trace --skip-core-file --max-binlog-size=64K --innodb-log-file-size=64M

View File

@@ -0,0 +1,45 @@
include/master-slave.inc
[connection master]
connection slave;
include/stop_slave.inc
SET GLOBAL gtid_slave_pos= '';
connection master;
RESET MASTER;
DROP TABLE IF EXISTS t1, t2;
Warnings:
Note 1051 Unknown table 'test.t1,test.t2'
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT, b INT, c VARCHAR(4000)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
# Flush all dirty pages from buffer pool
SET @no_checkpoint_save_pct= @@GLOBAL.innodb_max_dirty_pages_pct;
SET @no_checkpoint_save_pct_lwm= @@GLOBAL.innodb_max_dirty_pages_pct_lwm;
SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0;
SET GLOBAL innodb_max_dirty_pages_pct=0.0;
SET GLOBAL innodb_max_dirty_pages_pct= @no_checkpoint_save_pct;
SET GLOBAL innodb_max_dirty_pages_pct_lwm= @no_checkpoint_save_pct_lwm;
CHECKSUM TABLE t1, t2;
Table Checksum
test.t1 659068978
test.t2 4017444020
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
SELECT 1;
Got one of the listed errors
connection default;
HULU
BULU
connection server_1;
connection master;
include/save_master_gtid.inc
connection slave;
include/start_slave.inc
include/sync_with_master_gtid.inc
CHECKSUM TABLE t1, t2;
Table Checksum
test.t1 659068978
test.t2 4017444020
connection master;
DROP TABLE t1, t2;
include/rpl_end.inc

View File

@@ -0,0 +1,120 @@
--source include/not_embedded.inc
--source include/not_valgrind.inc
--source include/have_debug.inc
--source include/have_binlog_format_row.inc
--source include/master-slave.inc
--source include/have_innodb_binlog.inc
--let $pre_count= 4
--let $mid_count= 55
--connection slave
--source include/stop_slave.inc
SET GLOBAL gtid_slave_pos= '';
--connection master
--let $datadir= `SELECT @@datadir`
RESET MASTER;
DROP TABLE IF EXISTS t1, t2;
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
CREATE TABLE t2 (a INT PRIMARY KEY AUTO_INCREMENT, b INT, c VARCHAR(4000)) ENGINE=InnoDB;
INSERT INTO t1 VALUES (1);
--disable_query_log
--let $i= 0
while ($i < $pre_count) {
eval INSERT INTO t1 VALUES (100+$i);
eval INSERT INTO t2(b, c) VALUES ($i, repeat(chr(65 + ($i MOD 27)), 3500));
inc $i;
}
--enable_query_log
--let $no_checkpoint_flush= 1
--let $no_checkpoint_kill= 1
--source ../../suite/innodb/include/no_checkpoint_start.inc
--let $file= query_get_value(SHOW MASTER STATUS, File, 1)
--let $pos= query_get_value(SHOW MASTER STATUS, Position, 1)
--disable_query_log
--let $i= 0
while ($i < $mid_count) {
eval INSERT INTO t1 VALUES (1000+$i);
eval INSERT INTO t2(b, c) VALUES ($i, repeat(chr(65 + ($i MOD 27)), 3500));
inc $i;
}
--enable_query_log
CHECKSUM TABLE t1, t2;
# Crash the server
# Set $_expect_file_name for no_checkpoint_end.inc which uses start_mysqld.inc
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--write_file $_expect_file_name
wait-recovery.test
EOF
SET SESSION debug_dbug="+d,crash_dispatch_command_before";
--error 2006,2013
SELECT 1;
--source include/wait_until_disconnected.inc
--connection default
--source include/wait_until_disconnected.inc
--source ../../suite/innodb/include/no_checkpoint_end.inc
--echo HULU
# Overwrite the binlog file past the last checkpoint
# But only in the two most recent files, the prior ones are durably flushed
# and will not be recovered.
--let BINLOG_FILE= $datadir/$file
--let OFFSET= $pos
--let LEN=5000
perl;
my $orig_file= $ENV{BINLOG_FILE};
my $orig_pos= $ENV{OFFSET};
$orig_file =~ m/(.*binlog-)([0-9]{6})\.ibb/ or die "Unexpected file name $file";
my ($base, $seq)= ($1, $2);
for (;;) {
my $file= $base . sprintf("%06d", $seq) . ".ibb";
last unless -f $file;
my $file_plus_2= $base . sprintf("%06d", $seq+2) . ".ibb";
++$seq;
next if -f $file_plus_2;
my $pos= $file eq $orig_file ? $orig_pos : 0;
open F, '+<', $file or die $!;
sysseek F, $pos, 0 or die $!;
my $x= chr(0) x $ENV{LEN};
syswrite F, $x, $ENV{LEN} or die $!;
}
EOF
--echo BULU
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
--enable_reconnect
--source include/wait_until_connected_again.inc
--connection server_1
--enable_reconnect
--source include/wait_until_connected_again.inc
--connection master
--enable_reconnect
--source include/wait_until_connected_again.inc
--source include/save_master_gtid.inc
--connection slave
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
CHECKSUM TABLE t1, t2;
--connection master
DROP TABLE t1, t2;
--source include/rpl_end.inc