You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.3 KiB

MDEV-24035 Failing assertion: UT_LIST_GET_LEN(lock.trx_locks) == 0 causing disruption and replication failure 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
10 months ago
  1. #
  2. # Test of wrong call to unlock_row
  3. # MDEV-5629 Failing assertion: state == TRX_STATE_NOT_STARTED on
  4. # concurrent CREATE OR REPLACE and transactional UPDATE
  5. #
  6. --disable_query_log
  7. call mtr.add_suppression("InnoDB: Transaction was aborted due to ");
  8. --enable_query_log
  9. --source include/have_innodb.inc
  10. CREATE TABLE t1 (a INT, b INT) ENGINE=InnoDB;
  11. INSERT INTO t1 VALUES (1,1),(2,2);
  12. CREATE TABLE t2 (c INT, d INT) ENGINE=InnoDB;
  13. INSERT INTO t2 VALUES (1,1), (2,2);
  14. CREATE TABLE t3 (e INT) ENGINE=InnoDB;
  15. CREATE TABLE t4 ENGINE=InnoDB AS SELECT * FROM t2;
  16. --connect (con11,localhost,root,,test)
  17. BEGIN;
  18. UPDATE t1 SET a = 0 WHERE a = ( SELECT e FROM t3 );
  19. --connect (con12,localhost,root,,test)
  20. --send
  21. UPDATE t4 SET d = 1 WHERE d in ( SELECT a FROM t1 ) ORDER BY c LIMIT 6;
  22. --connection con11
  23. # Wait for con12 to start waiting for con11
  24. let $wait_condition=
  25. select count(*) = 1 from information_schema.innodb_trx
  26. where trx_state = "lock wait" and
  27. trx_query like "%SELECT a FROM t1%";
  28. --source include/wait_condition.inc
  29. UPDATE t4 SET d = 9;
  30. --connection con12
  31. --error ER_LOCK_DEADLOCK
  32. --reap
  33. --connection con11
  34. commit;
  35. --connection default
  36. --disconnect con12
  37. --disconnect con11
  38. drop table t1,t2,t3,t4;
  39. call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction");
  40. call mtr.add_suppression("Sort aborted.*");