mirror of
https://github.com/MariaDB/server.git
synced 2025-07-14 13:41:20 +03:00
Problem: ======= When the semisync master is crashed and restarted as slave it could recover transactions that former slaves may never have seen. A known method existed to clear out all prepared transactions with --tc-heuristic-recover=rollback does not care to adjust binlog accordingly. Fix: === The binlog-based recovery is made to concern of the slave semisync role of post-crash restarted server. No changes in behavior is done to the "normal" binloggging server and the semisync master. When the restarted server is configured with --rpl-semi-sync-slave-enabled=1 the refined recovery attempts to roll back prepared transactions and truncate binlog accordingly. In case of a partially committed (that is committed at least in one of the engine participants) such transaction gets committed. It's guaranteed no (partially as well) committed transactions exist beyond the truncate position. In case there exists a non-transactional replication event (being in a way a committed transaction) past the computed truncate position the recovery ends with an error. As after master crash and failover to slave, the demoted-to-slave ex-master must be ready to face and accept its own (generated by) events, without generally necessary --replicate-same-server-id. So the acceptance conditions are relaxed for the semisync slave to accept own events without that option. While gtid_strict_mode ON ensures no duplicate transaction can be (re-)executed the master_use_gtid=none slave has to be configured with --replicate-same-server-id. *NOTE* for reviewers. This patch does not handle the user XA which is done in next git commit.
74 lines
1.8 KiB
PHP
74 lines
1.8 KiB
PHP
#
|
|
# Invoked by binlog_truncate_multi_engine.test
|
|
# Parameters:
|
|
# $debug_sync_action describes debug-sync actions
|
|
# $kill_server 1 when to crash, 0 for regular restart
|
|
# $restart_parameters the caller may simulate partial commit at recovery
|
|
# $test_outcome summary of extected results
|
|
# $MYSQLD_DATADIR
|
|
|
|
--echo #
|
|
--echo #
|
|
--echo # Case $case : $description
|
|
--echo #
|
|
RESET MASTER;
|
|
FLUSH LOGS;
|
|
SET GLOBAL max_binlog_size= 4096;
|
|
|
|
connect(con1,localhost,root,,);
|
|
--echo List of binary logs before rotation
|
|
--source include/show_binary_logs.inc
|
|
INSERT INTO t1 VALUES (1, REPEAT("x", 1));
|
|
INSERT INTO t2 VALUES (1, REPEAT("x", 1));
|
|
if (`SELECT $case = "B"`)
|
|
{
|
|
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
|
wait-binlog_truncate_multi_engine.test
|
|
EOF
|
|
|
|
SET GLOBAL debug_dbug="d,enable_log_write_upto_crash";
|
|
}
|
|
BEGIN;
|
|
INSERT INTO t2 VALUES (2, REPEAT("x", 4100));
|
|
INSERT INTO t1 VALUES (2, REPEAT("x", 4100));
|
|
|
|
if (`SELECT $debug_sync_action != ""`)
|
|
{
|
|
--eval SET DEBUG_SYNC= $debug_sync_action
|
|
}
|
|
send COMMIT;
|
|
|
|
--connection default
|
|
if (`SELECT $case = "B"`)
|
|
{
|
|
--source include/wait_until_disconnected.inc
|
|
--source include/start_mysqld.inc
|
|
}
|
|
if (`SELECT $case != "B"`)
|
|
{
|
|
SET DEBUG_SYNC= "now WAIT_FOR con1_ready";
|
|
--echo List of binary logs after rotation
|
|
--source include/show_binary_logs.inc
|
|
|
|
--echo # restart the server with $restart_parameters
|
|
--echo # the server is restarted
|
|
--source include/restart_mysqld.inc
|
|
}
|
|
|
|
--connection default
|
|
--echo #
|
|
--echo # *** Summary: $test_outcome:
|
|
--echo #
|
|
SELECT COUNT(*) FROM t1;
|
|
SELECT COUNT(*) FROM t2;
|
|
SELECT @@GLOBAL.gtid_binlog_state;
|
|
SELECT @@GLOBAL.gtid_binlog_pos;
|
|
--echo List of binary logs at the end of the tests
|
|
--source include/show_binary_logs.inc
|
|
--echo # ***
|
|
# cleanup
|
|
DELETE FROM t1;
|
|
DELETE FROM t2;
|
|
--disconnect con1
|
|
--echo #
|