Commit 485a1b1f authored by Marko Mäkelä's avatar Marko Mäkelä

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 3e2ad0e9
of commit 0de3be8c
(that is, innodb_undo_log_truncate=ON would never be "completed").

Tested by: Matthias Leich
parent c28d1a6f
......@@ -129,7 +129,8 @@ struct alignas(CPU_LEVEL1_DCACHE_LINESIZE) trx_rseg_t
#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)); }
......
......@@ -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.
......
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment