Skip to content
/ server Public
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion extra/mariabackup/xtrabackup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5515,7 +5515,7 @@ static bool xtrabackup_backup_func()

/* get current checkpoint_lsn */
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
mysql_mutex_lock(&recv_sys.mutex);
dberr_t err = recv_sys.find_checkpoint();
log_sys.latch.wr_unlock();
Expand Down
2 changes: 0 additions & 2 deletions mysql-test/suite/perfschema/r/sxlock_func.result
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ name
wait/synch/rwlock/innodb/dict_operation_lock
wait/synch/rwlock/innodb/fil_space_latch
wait/synch/rwlock/innodb/lock_latch
wait/synch/rwlock/innodb/log_latch
wait/synch/rwlock/innodb/trx_i_s_cache_lock
wait/synch/rwlock/innodb/trx_purge_latch
wait/synch/rwlock/innodb/trx_rseg_latch
Expand Down Expand Up @@ -44,7 +43,6 @@ ORDER BY event_name;
event_name
wait/synch/rwlock/innodb/fil_space_latch
wait/synch/rwlock/innodb/lock_latch
wait/synch/rwlock/innodb/log_latch
SELECT event_name FROM performance_schema.events_waits_history_long
WHERE event_name = 'wait/synch/sxlock/innodb/index_tree_rw_lock'
AND operation IN ('try_shared_lock','shared_lock') LIMIT 1;
Expand Down
14 changes: 7 additions & 7 deletions storage/innobase/buf/buf0flu.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1854,7 +1854,7 @@ inline void log_t::write_checkpoint(lsn_t checkpoint, lsn_t end_lsn) noexcept

if (srv_file_flush_method != SRV_O_DSYNC)
ut_a(log.flush());
latch.wr_lock(SRW_LOCK_CALL);
latch.wr_lock();
resizing= resize_lsn.load(std::memory_order_relaxed);
}

Expand Down Expand Up @@ -2009,7 +2009,7 @@ static void log_checkpoint_low(lsn_t oldest_lsn, lsn_t end_lsn) noexcept
{
log_sys.latch.wr_unlock();
log_write_up_to(flush_lsn, true);
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
}

ut_ad(oldest_lsn > log_sys.last_checkpoint_lsn);
Expand Down Expand Up @@ -2042,7 +2042,7 @@ static void log_checkpoint() noexcept
fil_flush_file_spaces();
}

log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
const lsn_t end_lsn= log_sys.get_lsn();
mysql_mutex_lock(&buf_pool.flush_list_mutex);
const lsn_t oldest_lsn= buf_pool.get_oldest_modification(end_lsn);
Expand Down Expand Up @@ -2089,7 +2089,7 @@ ATTRIBUTE_COLD void buf_flush_wait(lsn_t lsn, bool checkpoint) noexcept
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
os_aio_wait_until_no_pending_writes(false);

log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
mysql_mutex_lock(&buf_pool.flush_list_mutex);

if (checkpoint)
Expand Down Expand Up @@ -2216,7 +2216,7 @@ static void buf_flush_sync_for_checkpoint(lsn_t lsn) noexcept
fil_flush_file_spaces();
}

log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
const lsn_t newest_lsn= log_sys.get_lsn();
mysql_mutex_lock(&buf_pool.flush_list_mutex);
lsn_t measure= buf_pool.get_oldest_modification(0);
Expand All @@ -2228,7 +2228,7 @@ static void buf_flush_sync_for_checkpoint(lsn_t lsn) noexcept
{
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
log_checkpoint_low(checkpoint_lsn, newest_lsn);
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
mysql_mutex_lock(&buf_pool.flush_list_mutex);
measure= buf_pool.get_oldest_modification(0);
}
Expand Down Expand Up @@ -2791,7 +2791,7 @@ ATTRIBUTE_COLD void buf_flush_sync_batch(lsn_t lsn, bool checkpoint) noexcept
{
thd_wait_begin(nullptr, THD_WAIT_DISKIO);
tpool::tpool_wait_begin();
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
lsn= std::max(lsn, log_sys.get_lsn());
mysql_mutex_lock(&buf_pool.flush_list_mutex);
buf_flush_wait(lsn, checkpoint);
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/fil/fil0fil.cc
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,7 @@ bool fil_space_free(uint32_t id, bool x_latched) noexcept
}

if (!recv_recovery_is_on()) {
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();

if (space->max_lsn) {
ut_d(space->max_lsn = 0);
Expand Down Expand Up @@ -1596,7 +1596,7 @@ fil_space_t *fil_space_t::drop(uint32_t id, pfs_os_file_t *detached_handle)
fil_system.named_spaces. Before we set the STOPPING_WRITES flag, another
concurrent operation could have marked the tablespace dirty again.
This clean-up corresponds to fil_space_free(). */
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
ut_ad((space->pending() & ~NEEDS_FSYNC) == (STOPPING | CLOSING));
if (space->max_lsn != 0)
{
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/fsp/fsp0sysspace.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,7 +616,7 @@ inline dberr_t SysTablespace::read_lsn_and_check_flags()
if (!log_sys.file_size && log_sys.format == log_t::FORMAT_3_23
&& srv_operation == SRV_OPERATION_NORMAL
&& srv_force_recovery < SRV_FORCE_NO_LOG_REDO) {
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
/* Upgrade from 0-sized ib_logfile0. */
log_sys.last_checkpoint_lsn = mach_read_from_8(
first_page + 26/*FIL_PAGE_FILE_FLUSH_LSN*/);
Expand Down
10 changes: 4 additions & 6 deletions storage/innobase/handler/ha_innodb.cc
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ static void innodb_max_purge_lag_wait_update(THD *thd, st_mysql_sys_var *,
if (thd_kill_level(thd))
break;
/* Adjust for purge_coordinator_state::refresh() */
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
const lsn_t last= log_sys.last_checkpoint_lsn,
max_age= log_sys.max_checkpoint_age;
const lsn_t lsn= log_sys.get_lsn();
Expand Down Expand Up @@ -616,7 +616,6 @@ mysql_pfs_key_t trx_i_s_cache_lock_key;
mysql_pfs_key_t trx_purge_latch_key;
mysql_pfs_key_t trx_rseg_latch_key;
mysql_pfs_key_t lock_latch_key;
mysql_pfs_key_t log_latch_key;

/* all_innodb_rwlocks array contains rwlocks that are
performance schema instrumented if "UNIV_PFS_RWLOCK"
Expand All @@ -632,7 +631,6 @@ static PSI_rwlock_info all_innodb_rwlocks[] =
{ &trx_purge_latch_key, "trx_purge_latch", 0 },
{ &trx_rseg_latch_key, "trx_rseg_latch", 0 },
{ &lock_latch_key, "lock_latch", 0 },
{ &log_latch_key, "log_latch", 0 },
{ &index_tree_rw_lock_key, "index_tree_rw_lock", PSI_RWLOCK_FLAG_SX }
};
# endif /* UNIV_PFS_RWLOCK */
Expand Down Expand Up @@ -4736,7 +4734,7 @@ checkpoint complete when we have flushed the redo log.
If we have already flushed all relevant redo log, we notify immediately.*/
static void innodb_log_flush_request(void *cookie) noexcept
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
lsn_t flush_lsn= log_sys.get_flushed_lsn();
/* Load lsn relaxed after flush_lsn was loaded from the same cache line */
const lsn_t lsn= log_sys.get_lsn();
Expand Down Expand Up @@ -18467,7 +18465,7 @@ checkpoint_now_set(THD* thd, st_mysql_sys_var*, void*, const void *save)
mysql_mutex_unlock(&LOCK_global_system_variables);
while (!thd_kill_level(thd))
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
lsn_t cp= log_sys.last_checkpoint_lsn.load(std::memory_order_relaxed),
lsn= log_sys.get_lsn();
log_sys.latch.wr_unlock();
Expand Down Expand Up @@ -18694,7 +18692,7 @@ static void innodb_log_file_size_update(THD *thd, st_mysql_sys_var*,
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
if (!resizing || !log_sys.resize_running(thd))
break;
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
while (resizing > log_sys.get_lsn())
{
ut_ad(!log_sys.is_mmap());
Expand Down
4 changes: 2 additions & 2 deletions storage/innobase/include/log0log.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,14 +195,14 @@ struct log_t
/** log file size in bytes, including the header */
lsn_t file_size;

#ifdef LOG_LATCH_DEBUG
#if defined LOG_LATCH_DEBUG && defined UNIV_DEBUG
typedef srw_lock_debug log_rwlock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems srw_lock_debug still has the PFS instrumentation which required the SRW_LOCK_CALL arguments, but those were removed.
Compiling with WITH_INNODB_EXTRA_DEBUG=ON gives similar errors:

/repos/server-10-11/storage/innobase/buf/buf0flu.cc: In member function ‘void log_t::write_checkpoint(lsn_t, lsn_t)’:
/repos/server-10-11/storage/innobase/buf/buf0flu.cc:1857:18: error: no matching function for call to ‘srw_lock_debug::wr_lock()’
 1857 |     latch.wr_lock();
      |     ~~~~~~~~~~~~~^~
/repos/server-10-11/storage/innobase/buf/buf0flu.cc:1857:18: note: there is 1 candidate
In file included from /repos/server-10-11/storage/innobase/include/log0log.h:33,
                 from /repos/server-10-11/storage/innobase/include/buf0flu.h:30,
                 from /repos/server-10-11/storage/innobase/buf/buf0flu.cc:33:
/repos/server-10-11/storage/innobase/include/srw_lock.h:607:8: note: candidate 1: ‘void srw_lock_debug::wr_lock(const char*, unsigned int)’
  607 |   void wr_lock(SRW_LOCK_ARGS(const char *file, unsigned line)) noexcept;
      |        ^~~~~~~
/repos/server-10-11/storage/innobase/include/srw_lock.h:607:8: note: candidate expects 2 arguments, 0 provided

Maybe the PFS instrumentation should be removed from debug lock as well somehow?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is fixing the following combination:

cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DWITH_INNODB_EXTRA_DEBUG=ON …

In our internal testing, we use the rr record friendly option PLUGIN_PERFSCHEMA=NO. Yes, I noticed that the WITH_INNODB_EXTRA_DEBUG build would fail if that option is omitted.

Given that the excessive amount of conditional branches that PLUGIN_PERFSCHEMA is introducing (MDEV-33181) can hurt rr record performance by several orders of magnitude (I have observed over 1000× slowdown in the past), I didn’t want to spend more time on this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we can just abandon the LOG_LATCH_DEBUG effort in log_t and comment that it may be reintroduced by providing adequate non-PFS instrumented debug support?


bool latch_have_wr() const { return latch.have_wr(); }
bool latch_have_rd() const { return latch.have_rd(); }
bool latch_have_any() const { return latch.have_any(); }
#else
typedef srw_lock log_rwlock;
typedef srw_lock_low log_rwlock;
# ifndef UNIV_DEBUG
# elif defined SUX_LOCK_GENERIC
bool latch_have_wr() const { return true; }
Expand Down
1 change: 0 additions & 1 deletion storage/innobase/include/univ.i
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ extern mysql_pfs_key_t index_tree_rw_lock_key;
extern mysql_pfs_key_t index_online_log_key;
extern mysql_pfs_key_t trx_sys_rw_lock_key;
extern mysql_pfs_key_t lock_latch_key;
extern mysql_pfs_key_t log_latch_key;
extern mysql_pfs_key_t trx_rseg_latch_key;
# endif /* UNIV_PFS_RWLOCK */
#endif /* HAVE_PSI_INTERFACE */
16 changes: 8 additions & 8 deletions storage/innobase/log/log0log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ void log_t::create() noexcept
ut_ad(this == &log_sys);
ut_ad(!is_initialised());

latch.SRW_LOCK_INIT(log_latch_key);
latch.init();
write_lsn_offset= 0;
/* LSN 0 and 1 are reserved; @see buf_page_t::oldest_modification_ */
base_lsn.store(FIRST_LSN, std::memory_order_relaxed);
Expand Down Expand Up @@ -504,7 +504,7 @@ void log_t::close_file(bool really_close) noexcept
/** @return the current log sequence number (may be stale) */
lsn_t log_get_lsn() noexcept
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
lsn_t lsn= log_sys.get_lsn();
log_sys.latch.wr_unlock();
return lsn;
Expand All @@ -523,7 +523,7 @@ static void log_resize_acquire() noexcept
group_commit_lock::ACQUIRED);
}

log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
}

/** Release the latches that protect the log. */
Expand Down Expand Up @@ -924,7 +924,7 @@ void log_t::persist(lsn_t lsn) noexcept
ATTRIBUTE_NOINLINE
static void log_write_persist(lsn_t lsn) noexcept
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
log_sys.persist(lsn);
log_sys.latch.wr_unlock();
}
Expand Down Expand Up @@ -1167,7 +1167,7 @@ void log_write_up_to(lsn_t lsn, bool durable,
if (write_lock.acquire(lsn, durable ? nullptr : callback) ==
group_commit_lock::ACQUIRED)
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
pending_write_lsn= write_lock.release(log_sys.writer());
}

Expand Down Expand Up @@ -1231,7 +1231,7 @@ void log_t::clear_mmap() noexcept
#ifdef HAVE_PMEM
if (!is_opened())
{
ut_d(latch.wr_lock(SRW_LOCK_CALL));
ut_d(latch.wr_lock());
ut_ad(!resize_in_progress());
ut_ad(get_lsn() == get_flushed_lsn(std::memory_order_relaxed));
ut_d(latch.wr_unlock());
Expand Down Expand Up @@ -1299,7 +1299,7 @@ ATTRIBUTE_COLD void log_t::checkpoint_margin() noexcept

while (check_for_checkpoint())
{
latch.wr_lock(SRW_LOCK_CALL);
latch.wr_lock();
ut_ad(!recv_no_log_write);

if (!check_for_checkpoint())
Expand Down Expand Up @@ -1509,7 +1509,7 @@ log_print(
/*======*/
FILE* file) /*!< in: file where to print */
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();

const lsn_t lsn= log_sys.get_lsn();
mysql_mutex_lock(&buf_pool.flush_list_mutex);
Expand Down
10 changes: 5 additions & 5 deletions storage/innobase/log/log0recv.cc
Original file line number Diff line number Diff line change
Expand Up @@ -810,7 +810,7 @@ static struct
log_sys.latch.wr_unlock();
fil_space_t *space= fil_system.sys_space;
buf_block_t *free_block= buf_LRU_get_free_block(false);
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
mysql_mutex_lock(&recv_sys.mutex);

for (auto d= defers.begin(); d != defers.end(); )
Expand Down Expand Up @@ -3898,7 +3898,7 @@ bool recv_sys_t::apply_batch(uint32_t space_id, fil_space_t *&space,
unlock_relock:
mysql_mutex_unlock(&mutex);
relock:
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
relock_last:
mysql_mutex_lock(&mutex);
get_last:
Expand Down Expand Up @@ -4178,7 +4178,7 @@ void recv_sys_t::apply(bool last_batch)
recv_sys.mutex. */
free_block= buf_LRU_get_free_block(false);
if (!last_batch)
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
mysql_mutex_lock(&mutex);
pages_it= pages.begin();
}
Expand Down Expand Up @@ -4235,7 +4235,7 @@ void recv_sys_t::apply(bool last_batch)
{
buf_flush_sync_batch(lsn, false);
buf_pool_invalidate();
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
}
else if (srv_operation == SRV_OPERATION_RESTORE ||
srv_operation == SRV_OPERATION_RESTORE_EXPORT)
Expand Down Expand Up @@ -4835,7 +4835,7 @@ dberr_t recv_recovery_from_checkpoint_start()

recv_sys.recovery_on = true;

log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
log_sys.set_capacity();

/* Start reading the log from the checkpoint lsn. */
Expand Down
16 changes: 8 additions & 8 deletions storage/innobase/mtr/mtr0mtr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ static void insert_imported(buf_block_t *block)
{
if (block->page.oldest_modification() <= 1)
{
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
/* For unlogged mtrs (MTR_LOG_NO_REDO), we use the current system LSN. The
mtr that generated the LSN is either already committed or in mtr_t::commit.
Shared latch and relaxed atomics should be fine here as it is guaranteed
Expand Down Expand Up @@ -559,7 +559,7 @@ void mtr_t::commit_shrink(fil_space_t &space, uint32_t size)

log_write_and_flush_prepare();
m_latch_ex= true;
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();

const lsn_t start_lsn= do_write().first;
ut_d(m_log.erase());
Expand Down Expand Up @@ -670,7 +670,7 @@ bool mtr_t::commit_file(fil_space_t &space, const char *name)
const size_t size{crypt ? 8 + encrypt() : crc32c()};

log_write_and_flush_prepare();
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
finish_write(size);

if (!name && space.max_lsn)
Expand Down Expand Up @@ -877,7 +877,7 @@ ATTRIBUTE_COLD void log_t::append_prepare_wait(bool late, bool ex) noexcept
if (!late)
{
/* Wait for all threads to back off. */
latch.wr_lock(SRW_LOCK_CALL);
latch.wr_lock();
goto got_ex;
}

Expand Down Expand Up @@ -929,13 +929,13 @@ ATTRIBUTE_COLD void log_t::append_prepare_wait(bool late, bool ex) noexcept
log_write_up_to(lsn, false);
if (ex)
{
latch.wr_lock(SRW_LOCK_CALL);
latch.wr_lock();
return;
}
}

done:
latch.rd_lock(SRW_LOCK_CALL);
latch.rd_lock();
}

/** Reserve space in the log buffer for appending data.
Expand Down Expand Up @@ -1089,7 +1089,7 @@ std::pair<lsn_t,lsn_t> mtr_t::do_write() noexcept
const size_t len{log_sys.is_encrypted() ? 8 + encrypt() : crc32c()};

if (!m_latch_ex)
log_sys.latch.rd_lock(SRW_LOCK_CALL);
log_sys.latch.rd_lock();

if (UNIV_UNLIKELY(m_user_space && !m_user_space->max_lsn &&
!srv_is_undo_tablespace((m_user_space->id))))
Expand All @@ -1098,7 +1098,7 @@ std::pair<lsn_t,lsn_t> mtr_t::do_write() noexcept
{
m_latch_ex= true;
log_sys.latch.rd_unlock();
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
if (UNIV_UNLIKELY(m_user_space->max_lsn != 0))
goto func_exit;
}
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/row/row0mysql.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ static void row_mysql_delay_if_needed() noexcept
if (UNIV_UNLIKELY(delay != 0))
{
/* Adjust for purge_coordinator_state::refresh() */
log_sys.latch.rd_lock(SRW_LOCK_CALL);
log_sys.latch.rd_lock();
const lsn_t last= log_sys.last_checkpoint_lsn,
max_age= log_sys.max_checkpoint_age;
const lsn_t lsn= log_sys.get_flushed_lsn();
Expand Down
2 changes: 1 addition & 1 deletion storage/innobase/srv/srv0mon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1608,7 +1608,7 @@ srv_mon_process_existing_counter(
break;

case MONITOR_LSN_CHECKPOINT_AGE:
log_sys.latch.wr_lock(SRW_LOCK_CALL);
log_sys.latch.wr_lock();
value = static_cast<mon_type_t>(log_sys.get_lsn()
- log_sys.last_checkpoint_lsn);
log_sys.latch.wr_unlock();
Expand Down
Loading