mirror of
https://github.com/MariaDB/server.git
synced 2025-12-01 17:39:21 +03:00
MDEV-27342: Fix issue of recovery failure using new server id
Commit 6c39eaeb1 made the crash recovery dependent on server_id.
The crash recovery could fail when restoring a new instance from
original crashed data directory USING A NEW SERVER ID.
The issue doesn't exist in previous major versions before 10.6.
Root cause is when generating the input XID to be searched in the hash,
server id is populated with the current server id.
So if the server id changed when recovering, the XID couldn't be found
in the hash due to server id doesn't match.
This fix is to use original server id when creating the input XID
object in function `xarecover_do_commit_or_rollback`.
All new code of the whole pull request, including one or several files
that are either new files or modified ones, are contributed under the
BSD-new license. I am contributing on behalf of my employer Amazon Web
Services, Inc.
This commit is contained in:
committed by
Otto Kekäläinen
parent
572e34304e
commit
dafc5fb9c1
@@ -0,0 +1,17 @@
|
||||
========= Set server_id to 99 and prepare test table.
|
||||
SET GLOBAL server_id= 99;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
|
||||
========= Crash the server.
|
||||
SET SESSION debug_dbug="+d,crash_commit_after_log";
|
||||
INSERT INTO t1 VALUES (1, NULL);
|
||||
Got one of the listed errors
|
||||
========= Restart the server with default config file in which server_id= 1.
|
||||
========= Check that recover succeeds and server is up.
|
||||
connection default;
|
||||
========= Check that all transactions are recovered.
|
||||
SELECT a FROM t1 ORDER BY a;
|
||||
a
|
||||
1
|
||||
========= Cleanup.
|
||||
connection default;
|
||||
DROP TABLE t1;
|
||||
@@ -0,0 +1,44 @@
|
||||
# This test verifies attempt to xa recover using a new server id that
|
||||
# different from the transaction's original server_id.
|
||||
#
|
||||
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_debug.inc
|
||||
--source include/have_binlog_format_row.inc
|
||||
# Valgrind does not work well with test that crashes the server
|
||||
--source include/not_valgrind.inc
|
||||
|
||||
|
||||
--echo ========= Set server_id to 99 and prepare test table.
|
||||
SET GLOBAL server_id= 99;
|
||||
CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
|
||||
|
||||
|
||||
--echo ========= Crash the server.
|
||||
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
wait-binlog_xa_recover_using_new_server_id.test
|
||||
EOF
|
||||
SET SESSION debug_dbug="+d,crash_commit_after_log";
|
||||
--error 2006,2013
|
||||
INSERT INTO t1 VALUES (1, NULL);
|
||||
|
||||
|
||||
--echo ========= Restart the server with default config file in which server_id= 1.
|
||||
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
|
||||
restart-binlog_xa_recover_using_new_server_id.test
|
||||
EOF
|
||||
|
||||
|
||||
--echo ========= Check that recover succeeds and server is up.
|
||||
connection default;
|
||||
--enable_reconnect
|
||||
--source include/wait_until_connected_again.inc
|
||||
|
||||
|
||||
--echo ========= Check that all transactions are recovered.
|
||||
SELECT a FROM t1 ORDER BY a;
|
||||
|
||||
|
||||
--echo ========= Cleanup.
|
||||
connection default;
|
||||
DROP TABLE t1;
|
||||
Reference in New Issue
Block a user