diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2023-04-18 14:54:40 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2023-04-18 14:54:40 +0300 |
commit | 485a1b1f116f0c5e73fce3a97ffdac84c861b3c2 (patch) | |
tree | 97701b09fe7337aaefe13cf624fcb391ced8b097 | |
parent | c28d1a6fea4f7ef14c545e4e59814a381b136642 (diff) | |
download | mariadb-git-485a1b1f116f0c5e73fce3a97ffdac84c861b3c2.tar.gz |
MDEV-30863 Server freeze, all threads in trx_assign_rseg_low()
trx_assign_rseg_low(): Simplify the debug check.
trx_rseg_t::reinit(): Reset the skip_allocation() flag.
This logic was broken in the merge
commit 3e2ad0e918d5d38322994ec9e08fc5dda3a80707
of commit 0de3be8cfdfc26f5c236eaefe12d03c7b4af22c8
(that is, innodb_undo_log_truncate=ON would never be "completed").
Tested by: Matthias Leich
-rw-r--r-- | storage/innobase/include/trx0rseg.h | 3 | ||||
-rw-r--r-- | storage/innobase/trx/trx0rseg.cc | 1 | ||||
-rw-r--r-- | storage/innobase/trx/trx0trx.cc | 20 |
3 files changed, 8 insertions, 16 deletions
diff --git a/storage/innobase/include/trx0rseg.h b/storage/innobase/include/trx0rseg.h index 8b7eacbbc18..1d95b7d2e7a 100644 --- a/storage/innobase/include/trx0rseg.h +++ b/storage/innobase/include/trx0rseg.h @@ -129,7 +129,8 @@ public: #endif } /** @return whether the segment is marked for undo truncation */ - bool skip_allocation() const { return ref_load() & SKIP; } + bool skip_allocation() const + { return ref.load(std::memory_order_acquire) & SKIP; } /** Increment the reference count */ void acquire() { ut_d(auto r=) ref.fetch_add(REF); ut_ad(!(r & SKIP)); } diff --git a/storage/innobase/trx/trx0rseg.cc b/storage/innobase/trx/trx0rseg.cc index d30300d70a7..6d95dcf06f1 100644 --- a/storage/innobase/trx/trx0rseg.cc +++ b/storage/innobase/trx/trx0rseg.cc @@ -403,6 +403,7 @@ void trx_rseg_t::reinit(uint32_t page) last_commit_and_offset= 0; last_page_no= FIL_NULL; curr_size= 1; + ref.store(0, std::memory_order_release); } /** Read the undo log lists. diff --git a/storage/innobase/trx/trx0trx.cc b/storage/innobase/trx/trx0trx.cc index d7ab02844bf..ed1187e179b 100644 --- a/storage/innobase/trx/trx0trx.cc +++ b/storage/innobase/trx/trx0trx.cc @@ -811,30 +811,20 @@ static void trx_assign_rseg_low(trx_t *trx) static Atomic_counter<unsigned> rseg_slot; unsigned slot = rseg_slot++ % TRX_SYS_N_RSEGS; ut_d(if (trx_rseg_n_slots_debug) slot = 0); + ut_d(const auto start_scan_slot = slot); trx_rseg_t* rseg; -#ifdef UNIV_DEBUG - ulint start_scan_slot = slot; - bool look_for_rollover = false; -#endif /* UNIV_DEBUG */ - bool allocated; do { for (;;) { rseg = &trx_sys.rseg_array[slot]; -#ifdef UNIV_DEBUG - /* Ensure that we are not revisiting the same - slot that we have already inspected. */ - if (look_for_rollover) { + do { + ut_d(if (!trx_rseg_n_slots_debug) continue); + slot = (slot + 1) % TRX_SYS_N_RSEGS; ut_ad(start_scan_slot != slot); - } - look_for_rollover = true; -#endif /* UNIV_DEBUG */ - - ut_d(if (!trx_rseg_n_slots_debug)) - slot = (slot + 1) % TRX_SYS_N_RSEGS; + } while (0); if (!rseg->space) { continue; |