mirror of
https://github.com/MariaDB/server.git
synced 2025-02-04 21:02:17 +01:00
f307160218
This commit contains a merge from 10.5-MDEV-29293-squash into 10.6. Although the bug MDEV-29293 was not reproducible with 10.6, the fix contains several improvements for wsrep KILL query and BF abort handling, and addresses the following issues: * MDEV-30307 KILL command issued inside a transaction is problematic for galera replication: This commit will remove KILL TOI replication, so Galera side transaction context is not lost during KILL. * MDEV-21075 KILL QUERY maintains nodes data consistency but breaks GTID sequence: This is fixed as well as KILL does not use TOI, and thus does not change GTID state. * MDEV-30372 Assertion in wsrep-lib state: This was caused by BF abort or KILL when local transaction was in the middle of group commit. This commit disables THD::killed handling during commit, so the problem is avoided. * MDEV-30963 Assertion failure !lock.was_chosen_as_deadlock_victim in trx0trx.h:1065: The assertion happened when the victim was BF aborted via MDL while it was committing. This commit changes MDL BF aborts so that transactions which are committing cannot be BF aborted via MDL. The RQG grammar attached in the issue could not reproduce the crash anymore. Original commit message from 10.5 fix: MDEV-29293 MariaDB stuck on starting commit state The problem seems to be a deadlock between KILL command execution and BF abort issued by an applier, where: * KILL has locked victim's LOCK_thd_kill and LOCK_thd_data. * Applier has innodb side global lock mutex and victim trx mutex. * KILL is calling innobase_kill_query, and is blocked by innodb global lock mutex. * Applier is in wsrep_innobase_kill_one_trx and is blocked by victim's LOCK_thd_kill. The fix in this commit removes the TOI replication of KILL command and makes KILL execution less intrusive operation. Aborting the victim happens now by using awake_no_mutex() and ha_abort_transaction(). If the KILL happens when the transaction is committing, the KILL operation is postponed to happen after the statement has completed in order to avoid KILL to interrupt commit processing. Notable changes in this commit: * wsrep client connections's error state may remain sticky after client connection is closed. This error message will then pop up for the next client session issuing first SQL statement. This problem raised with test galera.galera_bf_kill. The fix is to reset wsrep client error state, before a THD is reused for next connetion. * Release THD locks in wsrep_abort_transaction when locking innodb mutexes. This guarantees same locking order as with applier BF aborting. * BF abort from MDL was changed to do BF abort on server/wsrep-lib side first, and only then do the BF abort on InnoDB side. This removes the need to call back from InnoDB for BF aborts which originate from MDL and simplifies the locking. * Removed wsrep_thd_set_wsrep_aborter() from service_wsrep.h. The manipulation of the wsrep_aborter can be done solely on server side. Moreover, it is now debug only variable and could be excluded from optimized builds. * Remove LOCK_thd_kill from wsrep_thd_LOCK/UNLOCK to allow more fine grained locking for SR BF abort which may require locking of victim LOCK_thd_kill. Added explicit call for wsrep_thd_kill_LOCK/UNLOCK where appropriate. * Wsrep-lib was updated to version which allows external locking for BF abort calls. Changes to MTR tests: * Disable galera_bf_abort_group_commit. This test is going to be removed (MDEV-30855). * Make galera_var_retry_autocommit result more readable by echoing cases and expectations into result. Only one expected result for reap to verify that server returns expected status for query. * Record galera_gcache_recover_manytrx as result file was incomplete. Trivial change. * Make galera_create_table_as_select more deterministic: Wait until CTAS execution has reached MDL wait for multi-master conflict case. Expected error from multi-master conflict is ER_QUERY_INTERRUPTED. This is because CTAS does not yet have open wsrep transaction when it is waiting for MDL, query gets interrupted instead of BF aborted. This should be addressed in separate task. * A new test galera_bf_abort_registering to check that registering trx gets BF aborted through MDL. * A new test galera_kill_group_commit to verify correct behavior when KILL is executed while the transaction is committing. Co-authored-by: Seppo Jaakola <seppo.jaakola@iki.fi> Co-authored-by: Jan Lindström <jan.lindstrom@galeracluster.com> Signed-off-by: Julius Goryavsky <julius.goryavsky@mariadb.com>
163 lines
4.1 KiB
Text
163 lines
4.1 KiB
Text
#
|
|
# Test that the wsrep_retry_autocommit variable is respected.
|
|
#
|
|
|
|
--source include/galera_cluster.inc
|
|
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
--source include/have_debug_sync.inc
|
|
--source include/galera_have_debug_sync.inc
|
|
|
|
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
|
|
|
|
#
|
|
# With wsrep_retry_autocommit = 0, error is certain
|
|
#
|
|
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
SET SESSION wsrep_retry_autocommit = 0;
|
|
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue';
|
|
--send INSERT INTO t1 (f1) VALUES (2)
|
|
|
|
--connection node_1a
|
|
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
|
|
|
--connection node_2
|
|
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
|
--source include/wait_condition.inc
|
|
TRUNCATE TABLE t1;
|
|
|
|
--connection node_1
|
|
--error ER_LOCK_DEADLOCK
|
|
--reap
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
SET DEBUG_SYNC = 'RESET';
|
|
DROP TABLE t1;
|
|
|
|
|
|
#
|
|
# With wsrep_retry_autocommit = 1, success against one TRUNCATE
|
|
#
|
|
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
SET SESSION wsrep_retry_autocommit = 1;
|
|
SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit';
|
|
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue';
|
|
--send INSERT INTO t1 (f1) VALUES (3)
|
|
|
|
--connection node_1a
|
|
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
|
|
|
--connection node_2
|
|
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
|
--source include/wait_condition.inc
|
|
TRUNCATE TABLE t1;
|
|
|
|
--connection node_1a
|
|
SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached';
|
|
SELECT COUNT(*) FROM t1;
|
|
SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
|
|
|
|
--connection node_1
|
|
--error 0,ER_LOCK_DEADLOCK
|
|
--reap
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
SET DEBUG_SYNC = 'RESET';
|
|
SET GLOBAL debug_dbug = NULL;
|
|
DROP TABLE t1;
|
|
|
|
|
|
#
|
|
# With wsrep_retry_autcommit = 1, failure against multiple TRUNCATEs
|
|
#
|
|
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
SET SESSION wsrep_retry_autocommit = 1;
|
|
SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit';
|
|
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue EXECUTE 2';
|
|
|
|
--send INSERT INTO t1 VALUES (4);
|
|
|
|
--connection node_1a
|
|
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
|
|
|
--connection node_2
|
|
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
|
--source include/wait_condition.inc
|
|
TRUNCATE TABLE t1;
|
|
|
|
--connection node_1a
|
|
SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached';
|
|
SELECT COUNT(*) FROM t1;
|
|
SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue WAIT_FOR before_cert';
|
|
|
|
--connection node_2
|
|
TRUNCATE TABLE t1;
|
|
|
|
--connection node_1a
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
--connection node_1
|
|
--error 0,ER_LOCK_DEADLOCK
|
|
--reap
|
|
|
|
SET DEBUG_SYNC = 'RESET';
|
|
SET GLOBAL debug_dbug = NULL;
|
|
DROP TABLE t1;
|
|
|
|
|
|
#
|
|
# With wsrep_retry_autocommit = 64, success against 64 TRUNCATEs
|
|
#
|
|
|
|
--connection node_1
|
|
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
|
|
|
|
SET SESSION wsrep_retry_autocommit = 64;
|
|
SET GLOBAL debug_dbug = '+d,sync.wsrep_retry_autocommit';
|
|
SET DEBUG_SYNC = 'wsrep_before_certification SIGNAL before_cert WAIT_FOR continue EXECUTE 64';
|
|
|
|
--send INSERT INTO t1 VALUES (5)
|
|
|
|
--connection node_2
|
|
--let $wait_condition = SELECT count(*)=1 FROM information_schema.TABLES WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'
|
|
--source include/wait_condition.inc
|
|
|
|
--connection node_1
|
|
--disable_query_log
|
|
--disable_result_log
|
|
--let $count = 64
|
|
while ($count)
|
|
{
|
|
--connection node_1a
|
|
SET DEBUG_SYNC = 'now WAIT_FOR before_cert';
|
|
|
|
--connection node_2
|
|
TRUNCATE TABLE t1;
|
|
|
|
--connection node_1a
|
|
SET DEBUG_SYNC = 'now WAIT_FOR wsrep_retry_autocommit_reached';
|
|
SELECT COUNT(*) FROM t1;
|
|
SET DEBUG_SYNC = 'now SIGNAL wsrep_retry_autocommit_continue';
|
|
|
|
--dec $count
|
|
}
|
|
--enable_result_log
|
|
--enable_query_log
|
|
|
|
--connection node_1
|
|
--error 0,ER_LOCK_DEADLOCK
|
|
--reap
|
|
SELECT COUNT(*) FROM t1;
|
|
|
|
SET DEBUG_SYNC = 'RESET';
|
|
SET GLOBAL debug_dbug = NULL;
|
|
DROP TABLE t1;
|