Details
-
Task
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Fixed
Description
The InnoDB deadlock checker is holding lock_sys.mutex for a long time. After MDEV-24671 and MDEV-24731, we could almost perform the check by using a combination of lock_sys.wait_mutex and individual trx_t::mutex to protect the reads of trx->lock.wait_lock (the field may change from a non-null pointer to another non-null pointer without holding lock_sys.wait_mutex).
We can do even better: use Brent’s cycle detection algorithm on trx->lock.wait_trx.. (a new field protected by lock_sys.wait_mutex), and then release lock_sys.wait_mutex, acquire lock_sys.mutex and reacquire lock_sys.wait_mutex to dump information on all transactions that participate in the the deadlock, as well as to choose the victim transaction to be the one with the smallest weight. No dynamic memory allocation is needed, except possibly for some character strings that are part of the output.
There may be at most 8×innodb_page_size active transactions (524,288 when using innodb_page_size=64k). It is probably easiest to treat a waits-for path that exceeds 255 steps as a deadlock. In the old implementation, the cut-off was 200.
The old deadlock reporter only displayed information about 2 transactions, even though a deadlock may involve multiple transactions.
Attachments
Issue Links
- causes
-
MDEV-25750 Assertion `wait_lock->is_waiting()' in lock_wait_rpl_report
- Closed
- is blocked by
-
MDEV-24671 Assertion failure in lock_wait_table_reserve_slot()
- Closed
-
MDEV-24731 Excessive mutex contention in DeadlockChecker::check_and_resolve()
- Closed
- relates to
-
MDEV-24948 thd_need_wait_reports() hurts performance
- Open
-
MDEV-29187 Deadlock output in InnoDB status always shows transaction (0)
- Closed
-
MDEV-18706 ER_LOCK_DEADLOCK on concurrent read and insert into already locked gap
- In Review
-
MDEV-25594 Crash in deadlock checker under high load
- Closed
-
MDEV-27025 insert-intention lock conflicts with waiting ORDINARY lock
- Closed
-
MDEV-30973 Enhance output of innodb deadlocks (SAMU-124, SAMU-131)
- In Review