1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-23 03:54:27 +03:00
Files
mariadb/mysql-test/suite/binlog/t/binlog_checkpoint.test
unknown 22f91eddb1 MDEV-4322: Race in binlog checkpointing during server shutdown.
During server shutdown, we need to wait for binlog checkpointing to
finish in the binlog background thread before closing the binlog.

This was not done, so we could get assert and failure to finish the
final binlog checkpoint if shutdown happened in the middle.
2013-03-25 12:05:27 +01:00

146 lines
5.0 KiB
Plaintext

--source include/have_innodb.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/have_binlog_format_row.inc
SET @old_max_binlog_size= @@global.max_binlog_size;
SET GLOBAL max_binlog_size= 4096;
SET @old_innodb_flush_log_at_trx_commit= @@global.innodb_flush_log_at_trx_commit;
SET GLOBAL innodb_flush_log_at_trx_commit= 1;
RESET MASTER;
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
CREATE TABLE t2 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Myisam;
--echo *** Test that RESET MASTER waits for pending commit checkpoints to complete.
# con1 will hang before doing commit checkpoint, blocking RESET MASTER.
connect(con1,localhost,root,,);
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con1_ready WAIT_FOR con1_go";
send INSERT INTO t1 VALUES (1, REPEAT("x", 4100));
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
# Let's add a few binlog rotations just for good measure.
INSERT INTO t2 VALUES (1, REPEAT("x", 4100));
INSERT INTO t2 VALUES (2, REPEAT("x", 4100));
--source include/show_binary_logs.inc
--let $binlog_file= master-bin.000004
--let $binlog_start= 4
--source include/show_binlog_events.inc
SET DEBUG_SYNC= "execute_command_after_close_tables SIGNAL reset_master_done";
send RESET MASTER;
connect(con2,localhost,root,,);
--echo This will timeout, as RESET MASTER is blocked
SET DEBUG_SYNC= "now WAIT_FOR reset_master_done TIMEOUT 1";
# Wake up transaction to allow RESET MASTER to complete.
SET DEBUG_SYNC= "now SIGNAL con1_go";
connection con1;
reap;
connection default;
reap;
--source include/show_binary_logs.inc
--let $binlog_file= master-bin.000001
--let $binlog_start= 4
--source include/show_binlog_events.inc
--echo *** Test that binlog N is active, and commit checkpoint for (N-1) is
--echo *** done while there is still a pending commit checkpoint for (N-2).
connection con1;
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con1_ready WAIT_FOR con1_continue";
send INSERT INTO t1 VALUES (20, REPEAT("x", 4100));
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
connection con2;
SET DEBUG_SYNC= "commit_after_group_release_commit_ordered SIGNAL con2_ready WAIT_FOR con2_continue";
send INSERT INTO t1 VALUES (21, REPEAT("x", 4100));
connection default;
SET DEBUG_SYNC= "now WAIT_FOR con2_ready";
--source include/show_binary_logs.inc
--let $binlog_file= master-bin.000001
--source include/show_binlog_events.inc
--let $binlog_file= master-bin.000002
--source include/show_binlog_events.inc
--let $binlog_file= master-bin.000003
--source include/show_binlog_events.inc
# We need to sync the test case with the background processing of the
# commit checkpoint, otherwise we get nondeterministic results.
SET DEBUG_SYNC= "RESET";
SET @old_dbug= @@global.DEBUG_DBUG;
SET GLOBAL debug_dbug="+d,binlog_background_checkpoint_processed";
SET DEBUG_SYNC= "now SIGNAL con2_continue";
connection con2;
reap;
connection default;
--echo con1 is still pending, no new binlog checkpoint should have been logged.
# Make sure commit checkpoint is processed before we check that no checkpoint
# event has been binlogged.
SET DEBUG_SYNC= "now WAIT_FOR binlog_background_checkpoint_processed";
SET GLOBAL debug_dbug= @old_dbug;
SET DEBUG_SYNC= "RESET";
--let $binlog_file= master-bin.000003
--source include/show_binlog_events.inc
SET DEBUG_SYNC= "now SIGNAL con1_continue";
connection con1;
reap;
connection default;
--echo No commit checkpoints are pending, a new binlog checkpoint should have been logged.
--let $binlog_file= master-bin.000003
# Wait for the master-bin.000003 binlog checkpoint to appear.
--let $wait_for_all= 0
--let $show_statement= SHOW BINLOG EVENTS IN "$binlog_file"
--let $field= Info
--let $condition= = "master-bin.000003"
--source include/wait_show_condition.inc
--source include/show_binlog_events.inc
--echo *** MDEV-4322: Broken XID counting during binlog rotation ***
# Test that binlog shutdown waits for any pending binlog checkpoints to have time to complete.
connection default;
# We will use debug_sync to setup a wait inside the background processing
# of binlog checkpoints. The wait is newer resumed, and will eventually
# time out. If server shutdown does not wait for checkpoint processing to
# complete, we will get an assert.
#
# It is a bit tricky to inject the wait properly as it has to happen in a
# background thread during shutdown. So we first inject a DBUG to set the
# debug_sync wait in the correct thread, then wait to be signalled that
# the inject happened so that we can remove it again from DBUG (else
# check_testcase will complain).
SET @old_dbug= @@global.DEBUG_DBUG;
SET GLOBAL debug_dbug="+d,inject_binlog_background_thread_before_mark_xid_done";
FLUSH LOGS;
INSERT INTO t1 VALUES (30, REPEAT("x", 4100));
SET DEBUG_SYNC= "now WAIT_FOR injected_binlog_background_thread";
SET GLOBAL debug_dbug= @old_dbug;
INSERT INTO t1 VALUES (31, REPEAT("x", 4100));
--source include/show_binary_logs.inc
DROP TABLE t1, t2;
SET GLOBAL max_binlog_size= @old_max_binlog_size;
SET GLOBAL innodb_flush_log_at_trx_commit= @old_innodb_flush_log_at_trx_commit;