Skip to content

Commit

Permalink
MDEV-33515 fixup: Clarify mtr_t::spin_wait_delay
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Mar 27, 2024
1 parent bf0b82d commit 0c6cac0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 18 deletions.
21 changes: 6 additions & 15 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions storage/innobase/include/mtr0mtr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/mtr/mtr0mtr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) ||
Expand Down

0 comments on commit 0c6cac0

Please sign in to comment.