[MDEV-28445] Secondary index locking invokes costly trx_sys.get_min_trx_id() Created: 2022-04-29  Updated: 2023-03-15  Resolved: 2022-04-29

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.3, 10.5, 10.6, 10.7, 10.8, 10.9
Fix Version/s: 10.6.8, 10.7.4, 10.8.3, 10.9.1

Type: Bug Priority: Major
Reporter: Marko Mäkelä Assignee: Marko Mäkelä
Resolution: Fixed Votes: 0
Labels: performance

Issue Links:
Problem/Incident
causes MDEV-30357 Performance regression in locking rea... Closed
Relates
relates to MDEV-20630 lf_hash get performance regression si... Confirmed
relates to MDEV-21423 lock-free trx_sys get performance reg... Stalled

 Description   

As noted in MDEV-21423, InnoDB is unnecessarily performing full traversal of the lock-free trx_sys.rw_trx_hash when enforcing locks on secondary indexes.

Apart from some recovery code, there are two sources of trx_sys.rw_trx_hash traversal, which will be affected by MDEV-20630:

  1. cloning a read view
    • in trx_sys.snapshot_ids() executed via ReadViewBase::snapshot() and ReadView::open()
    • in trx_sys.clone_oldest_view() executed via purge_sys.clone_oldest_view()
  2. determining the minimum transaction identifier in any read view

In MySQL 8.0.29, trx_rw_min_trx_id() was partly removed as redundant and partly replaced with a simpler operation.

I created something similar, replacing trx_sys.get_min_trx_id() with trx_sys.find_same_or_older(). I expect it to improve performance of operations that involve secondary indexes. The new hash table traversal trx_sys.find_same_or_older() employs short circuit evaluation, in a strictly read-only operation (not even acquiring any mutex).

This change did not affect performance (for the better or worse) in axel's benchmark test battery, so I do not think that we can claim that this cleanup fixes MDEV-21423. Nevertheless, I think that the cleanup is useful and it could benefit some other types workloads, possibly with more conflicts between secondary index record locks.


Generated at Thu Feb 08 10:00:48 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.