Commit 0c6cac0a authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-33515 fixup: Clarify mtr_t::spin_wait_delay

innodb_log_spin_wait_delay_update(): Always acquire log_sys.latch
to protect the change of mtr_t::spin_wait_delay.

log_t::lock_lsn(): In the general case, actually use
mtr_t::spin_wait_delay as it was intended. In the x86 specific
log_t::lock_lsn_bts() we used mtr_t::spin_wait_delay.
parent bf0b82d2
......@@ -18478,22 +18478,13 @@ static void innodb_log_file_size_update(THD *thd, st_mysql_sys_var*,
mysql_mutex_lock(&LOCK_global_system_variables);
}
static void innodb_log_spin_wait_delay_update(THD *thd, st_mysql_sys_var*,
void *var, const void *save)
static void innodb_log_spin_wait_delay_update(THD *, st_mysql_sys_var*,
void *, const void *save)
{
ut_ad(var == &mtr_t::spin_wait_delay);
unsigned delay= *static_cast<const unsigned*>(save);
if (!delay != !mtr_t::spin_wait_delay)
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
mtr_t::spin_wait_delay= delay;
mtr_t::finisher_update();
log_sys.latch.wr_unlock();
}
else
mtr_t::spin_wait_delay= delay;
log_sys.latch.wr_lock(SRW_LOCK_CALL);
mtr_t::spin_wait_delay= *static_cast<const unsigned*>(save);
mtr_t::finisher_update();
log_sys.latch.wr_unlock();
}
/** Update innodb_status_output or innodb_status_output_locks,
......
......@@ -715,8 +715,7 @@ struct mtr_t {
{ return finisher(this, len); }
public:
/** Poll interval in log_sys.lock_lsn(); 0 to use log_sys.lsn_lock.
Protected by LOCK_global_system_variables; changes to and from 0
are additionally protected by exclusive log_sys.latch. */
Protected by LOCK_global_system_variables and log_sys.latch. */
static unsigned spin_wait_delay;
/** Update finisher when spin_wait_delay is changing to or from 0. */
static void finisher_update();
......
......@@ -962,7 +962,7 @@ size_t log_t::lock_lsn() noexcept
size_t b= buf_free.fetch_or(buf_free_LOCK, std::memory_order_acquire);
if (b & buf_free_LOCK)
{
const size_t m= my_cpu_relax_multiplier * srv_spin_wait_delay / 32;
const size_t m= mtr_t::spin_wait_delay;
constexpr size_t DELAY= 10, MAX_ITERATIONS= 10;
for (size_t delay_count= DELAY, delay_iterations= 1;
((b= buf_free.load(std::memory_order_relaxed)) & buf_free_LOCK) ||
......
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