diff options
author | Daniel Black <daniel@mariadb.org> | 2022-07-26 18:41:37 +1000 |
---|---|---|
committer | Daniel Black <daniel@mariadb.org> | 2022-07-26 18:41:40 +1000 |
commit | cbaa771d12c55fe99979ac89ecd6d78a58ae7685 (patch) | |
tree | 055e8eaab9cec4218efd05aef0011ccf71b706a2 | |
parent | 2398cbc868210a6cfd47d3f434cff27202a0f1c8 (diff) | |
download | mariadb-git-bb-10.6-danielblack-MDEV-29141-rseg_ext_p2.tar.gz |
MDEV-29166: reduce locking of innodb trx_sys_t::history_*bb-10.6-danielblack-MDEV-29141-rseg_ext_p2
Acquire and release locks in trx_sys_t::history_* one by one so
we reduce the risk of deadlock with a process that acquires a
later segement and then aquires and earlier segment.
While doing this means that the accuracy of the returned history
length could be off by a factor, but by the time we release from
these microfunctions, the rseg locks are released, so the history
value is out of date by the time the calling function access it already.
reasons why not are https://jira.mariadb.org/browse/MDEV-29141?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
Pushing for test purposes only at the momement.
-rw-r--r-- | storage/innobase/trx/trx0sys.cc | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/storage/innobase/trx/trx0sys.cc b/storage/innobase/trx/trx0sys.cc index 2479e5a4cc1..66b535c7188 100644 --- a/storage/innobase/trx/trx0sys.cc +++ b/storage/innobase/trx/trx0sys.cc @@ -196,9 +196,8 @@ size_t trx_sys_t::history_size() { rseg.latch.rd_lock(SRW_LOCK_CALL); size+= rseg.history_size; - } - for (auto &rseg : rseg_array) rseg.latch.rd_unlock(); + } return size; } @@ -207,20 +206,17 @@ bool trx_sys_t::history_exceeds(size_t threshold) ut_ad(is_initialised()); size_t size= 0; bool exceeds= false; - size_t i; - for (i= 0; i < array_elements(rseg_array); i++) + for (auto &rseg : rseg_array) { - rseg_array[i].latch.rd_lock(SRW_LOCK_CALL); - size+= rseg_array[i].history_size; + rseg.latch.rd_lock(SRW_LOCK_CALL); + size+= rseg.history_size; + rseg.latch.rd_unlock(); if (size > threshold) { exceeds= true; - i++; break; } } - while (i) - rseg_array[--i].latch.rd_unlock(); return exceeds; } |