mirror of
https://github.com/MariaDB/server.git
synced 2025-02-04 21:02:17 +01:00
ddd7d5d8e3
Under unknown circumstances, the SQL layer may wrongly disregard an invocation of thd_mark_transaction_to_rollback() when an InnoDB transaction had been aborted (rolled back) due to one of the following errors: * HA_ERR_LOCK_DEADLOCK * HA_ERR_RECORD_CHANGED (if innodb_snapshot_isolation=ON) * HA_ERR_LOCK_WAIT_TIMEOUT (if innodb_rollback_on_timeout=ON) Such an error used to cause a crash of InnoDB during transaction commit. These changes aim to catch and report the error earlier, so that not only this crash can be avoided but also the original root cause be found and fixed more easily later. The idea of this fix is from Michael 'Monty' Widenius. HA_ERR_ROLLBACK: A new error code that will be translated into ER_ROLLBACK_ONLY, signalling that the current transaction has been aborted and the only allowed action is ROLLBACK. trx_t::state: Add TRX_STATE_ABORTED that is like TRX_STATE_NOT_STARTED, but noting that the transaction had been rolled back and aborted. trx_t::is_started(): Replaces trx_is_started(). ha_innobase: Check the transaction state in various places. Simplify the logic around SAVEPOINT. ha_innobase::is_valid_trx(): Replaces ha_innobase::is_read_only(). The InnoDB logic around transaction savepoints, commit, and rollback was unnecessarily complex and might have contributed to this inconsistency. So, we are simplifying that logic as well. trx_savept_t: Replace with const undo_no_t*. When we rollback to a savepoint, all we need to know is the number of undo log records that must survive. trx_named_savept_t, DB_NO_SAVEPOINT: Remove. We can store undo_no_t directly in the space allocated at innobase_hton->savepoint_offset. fts_trx_create(): Do not copy previous savepoints. fts_savepoint_rollback(): If a savepoint was not found, roll back everything after the default savepoint of fts_trx_create(). The test innodb_fts.savepoint is extended to cover this code. Reviewed by: Vladislav Lesin Tested by: Matthias Leich
89 lines
2.4 KiB
Text
89 lines
2.4 KiB
Text
--source include/have_innodb.inc
|
|
--source include/have_debug.inc
|
|
--source include/master-slave.inc
|
|
|
|
--disable_query_log
|
|
call mtr.add_suppression("InnoDB: Transaction was aborted due to ");
|
|
--enable_query_log
|
|
|
|
--echo MDEV-31655: Parallel replication deadlock victim preference code erroneously removed
|
|
# The problem was that InnoDB would choose the wrong deadlock victim.
|
|
# Create a lot of transactions that can cause deadlocks, and use error
|
|
# injection to check that the first transactions in each group is never
|
|
# selected as deadlock victim.
|
|
--let $rows= 10
|
|
--let $transactions= 5
|
|
--let $gcos= 10
|
|
|
|
--connection server_1
|
|
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
|
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
|
|
BEGIN;
|
|
--disable_query_log
|
|
--let $i= 0
|
|
while ($i < 10) {
|
|
eval INSERT INTO t1 VALUES ($i, 0);
|
|
inc $i;
|
|
}
|
|
--enable_query_log
|
|
COMMIT;
|
|
--source include/save_master_gtid.inc
|
|
|
|
--connection server_2
|
|
--source include/sync_with_master_gtid.inc
|
|
--source include/stop_slave.inc
|
|
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
|
|
SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
|
|
eval set @@global.slave_parallel_threads= $transactions;
|
|
set @@global.slave_parallel_mode= conservative;
|
|
SET @old_dbug= @@GLOBAL.debug_dbug;
|
|
# This error injection will allow no retries for GTIDs divisible by 1000.
|
|
SET GLOBAL debug_dbug= "+d,rpl_mdev31655_zero_retries";
|
|
|
|
--connection server_1
|
|
SET @old_dbug= @@SESSION.debug_dbug;
|
|
SET SESSION debug_dbug="+d,binlog_force_commit_id";
|
|
|
|
--let $j= 1
|
|
while ($j <= $gcos) {
|
|
eval SET @commit_id= $j+1000;
|
|
--let $i= 0
|
|
while ($i < $transactions) {
|
|
--disable_query_log
|
|
eval SET SESSION gtid_seq_no= 1000 + 1000*$j + $i;
|
|
BEGIN;
|
|
--let $k= 0
|
|
while ($k < $rows) {
|
|
eval UPDATE t1 SET b=b+1 WHERE a=(($i+$k) MOD $rows);
|
|
inc $k;
|
|
}
|
|
COMMIT;
|
|
--enable_query_log
|
|
inc $i;
|
|
}
|
|
inc $j;
|
|
}
|
|
|
|
SET SESSION debug_dbug= @old_dbug;
|
|
SELECT COUNT(*), SUM(a*100*b) FROM t1;
|
|
|
|
--source include/save_master_gtid.inc
|
|
|
|
--connection server_2
|
|
--source include/start_slave.inc
|
|
--source include/sync_with_master_gtid.inc
|
|
SET GLOBAL debug_dbug= @old_dbug;
|
|
SELECT COUNT(*), SUM(a*100*b) FROM t1;
|
|
|
|
|
|
# Clean up.
|
|
--connection server_2
|
|
--source include/stop_slave.inc
|
|
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
|
|
SET GLOBAL slave_parallel_mode=@old_parallel_mode;
|
|
--source include/start_slave.inc
|
|
|
|
--connection server_1
|
|
DROP TABLE t1;
|
|
|
|
--source include/rpl_end.inc
|