summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-01-11 17:54:49 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-01-11 17:54:49 +0200
commitd0948c88bd8d85981b6f034c695cee6305f4efbc (patch)
tree4b7b4d5d05b5e44d9f6cdbebac632f49317658d0
parentc1884122d70683c01003362a0660940515407beb (diff)
downloadmariadb-git-bb-10.8-MDEV-14425-flush_order_mutex.tar.gz
Test: Merge buf_pool.flush_order_mutex to log_sys.mutexbb-10.8-MDEV-14425-flush_order_mutex
This will actually reduce throughput by increasing contention on log_sys.mutex.
-rw-r--r--storage/innobase/buf/buf0flu.cc6
-rw-r--r--storage/innobase/fil/fil0crypt.cc1
-rw-r--r--storage/innobase/handler/ha_innodb.cc2
-rw-r--r--storage/innobase/include/log0log.h8
-rw-r--r--storage/innobase/include/univ.i1
-rw-r--r--storage/innobase/log/log0log.cc29
-rw-r--r--storage/innobase/mtr/mtr0mtr.cc15
7 files changed, 23 insertions, 39 deletions
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 1d3372c6714..193e43b61b1 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -177,7 +177,7 @@ void buf_pool_t::insert_into_flush_list(buf_block_t *block, lsn_t lsn)
mysql_mutex_assert_not_owner(&mutex);
#ifdef SAFE_MUTEX
if (!recv_recovery_is_on())
- mysql_mutex_assert_owner(&log_sys.flush_order_mutex);
+ mysql_mutex_assert_owner(&log_sys.mutex);
#endif /* SAFE_MUTEX */
ut_ad(lsn > 2);
static_assert(log_t::FIRST_LSN >= 2, "compatibility");
@@ -1799,10 +1799,8 @@ static bool log_checkpoint()
mysql_mutex_lock(&log_sys.mutex);
const lsn_t end_lsn= log_sys.get_lsn();
- mysql_mutex_lock(&log_sys.flush_order_mutex);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
const lsn_t oldest_lsn= buf_pool.get_oldest_modification(end_lsn);
- mysql_mutex_unlock(&log_sys.flush_order_mutex);
mysql_mutex_unlock(&buf_pool.flush_list_mutex);
return log_checkpoint_low(oldest_lsn, end_lsn);
}
@@ -1963,9 +1961,7 @@ ATTRIBUTE_COLD static void buf_flush_sync_for_checkpoint(lsn_t lsn)
mysql_mutex_lock(&log_sys.mutex);
const lsn_t newest_lsn= log_sys.get_lsn();
- mysql_mutex_lock(&log_sys.flush_order_mutex);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
- mysql_mutex_unlock(&log_sys.flush_order_mutex);
lsn_t measure= buf_pool.get_oldest_modification(0);
const lsn_t checkpoint_lsn= measure ? measure : newest_lsn;
diff --git a/storage/innobase/fil/fil0crypt.cc b/storage/innobase/fil/fil0crypt.cc
index cdcbdc953a4..e5c143ecc14 100644
--- a/storage/innobase/fil/fil0crypt.cc
+++ b/storage/innobase/fil/fil0crypt.cc
@@ -1871,7 +1871,6 @@ fil_crypt_rotate_page(
} else {
/* If block read failed mtr memo and log should be empty. */
ut_ad(!mtr.has_modifications());
- ut_ad(!mtr.is_dirty());
ut_ad(mtr.get_memo()->size() == 0);
ut_ad(mtr.get_log()->size() == 0);
mtr.commit();
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index f7f461b805e..b251fee8beb 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -536,7 +536,6 @@ mysql_pfs_key_t ibuf_mutex_key;
mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
mysql_pfs_key_t log_sys_mutex_key;
mysql_pfs_key_t log_cmdq_mutex_key;
-mysql_pfs_key_t log_flush_order_mutex_key;
mysql_pfs_key_t recalc_pool_mutex_key;
mysql_pfs_key_t purge_sys_pq_mutex_key;
mysql_pfs_key_t recv_sys_mutex_key;
@@ -572,7 +571,6 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(fts_cache_init_mutex),
PSI_KEY(fts_delete_mutex),
PSI_KEY(fts_doc_id_mutex),
- PSI_KEY(log_flush_order_mutex),
PSI_KEY(ibuf_bitmap_mutex),
PSI_KEY(ibuf_mutex),
PSI_KEY(ibuf_pessimistic_insert_mutex),
diff --git a/storage/innobase/include/log0log.h b/storage/innobase/include/log0log.h
index 618bda3b87a..565cd4be0c5 100644
--- a/storage/innobase/include/log0log.h
+++ b/storage/innobase/include/log0log.h
@@ -213,9 +213,6 @@ public:
size_t buf_free;
/** recommended maximum size of buf, after which the buffer is flushed */
size_t max_buf_free;
- /** mutex that ensures that inserts into buf_pool.flush_list are in
- LSN order; allows mtr_t::commit() to release log_sys.mutex earlier */
- MY_ALIGNED(CPU_LEVEL1_DCACHE_LINESIZE) mysql_mutex_t flush_order_mutex;
/** log record buffer, written to by mtr_t::commit() */
byte *buf;
/** buffer for writing data to ib_logfile0, or nullptr if is_pmem()
@@ -413,10 +410,11 @@ public:
@param end_lsn start LSN of the FILE_CHECKPOINT mini-transaction */
inline void write_checkpoint(lsn_t end_lsn) noexcept;
- /** Write buf to ib_logfile0 and release mutex.
+ /** Write buf to ib_logfile0.
+ @tparam release_mutex whether to release the mutex
@return new write target
@retval 0 if everything was written */
- inline lsn_t write_buf() noexcept;
+ template<bool release_mutex> inline lsn_t write_buf() noexcept;
/** Create the log. */
void create(lsn_t lsn) noexcept;
diff --git a/storage/innobase/include/univ.i b/storage/innobase/include/univ.i
index bef51549e73..e4aee2961e3 100644
--- a/storage/innobase/include/univ.i
+++ b/storage/innobase/include/univ.i
@@ -519,7 +519,6 @@ extern mysql_pfs_key_t ibuf_mutex_key;
extern mysql_pfs_key_t ibuf_pessimistic_insert_mutex_key;
extern mysql_pfs_key_t log_sys_mutex_key;
extern mysql_pfs_key_t log_cmdq_mutex_key;
-extern mysql_pfs_key_t log_flush_order_mutex_key;
extern mysql_pfs_key_t recalc_pool_mutex_key;
extern mysql_pfs_key_t purge_sys_pq_mutex_key;
extern mysql_pfs_key_t recv_sys_mutex_key;
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index c63b74edd8c..277907b3d08 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -125,11 +125,8 @@ void log_t::create()
#if defined(__aarch64__)
mysql_mutex_init(log_sys_mutex_key, &mutex, MY_MUTEX_INIT_FAST);
- mysql_mutex_init(
- log_flush_order_mutex_key, &flush_order_mutex, MY_MUTEX_INIT_FAST);
#else
mysql_mutex_init(log_sys_mutex_key, &mutex, nullptr);
- mysql_mutex_init(log_flush_order_mutex_key, &flush_order_mutex, nullptr);
#endif
/* LSN 0 and 1 are reserved; @see buf_page_t::oldest_modification_ */
@@ -514,7 +511,6 @@ static size_t log_pad(lsn_t lsn, size_t pad, byte *begin, byte *extra)
inline void log_t::persist(lsn_t lsn) noexcept
{
ut_ad(is_pmem());
- mysql_mutex_assert_not_owner(&mutex);
ut_ad(!write_lock.is_owner());
ut_ad(flush_lock.is_owner());
@@ -537,10 +533,11 @@ inline void log_t::persist(lsn_t lsn) noexcept
}
#endif
-/** Write buf to ib_logfile0 and release mutex.
+/** Write buf to ib_logfile0.
+@tparam release_mutex whether to release the mutex
@return new write target
@retval 0 if everything was written */
-inline lsn_t log_t::write_buf() noexcept
+template<bool release_mutex> inline lsn_t log_t::write_buf() noexcept
{
mysql_mutex_assert_owner(&mutex);
@@ -552,7 +549,8 @@ inline lsn_t log_t::write_buf() noexcept
if (write_lsn >= lsn)
{
- mysql_mutex_unlock(&mutex);
+ if (release_mutex)
+ mysql_mutex_unlock(&mutex);
ut_ad(write_lsn == lsn);
}
else
@@ -591,7 +589,8 @@ inline lsn_t log_t::write_buf() noexcept
std::swap(buf, flush_buf);
write_to_log++;
- mysql_mutex_unlock(&mutex);
+ if (release_mutex)
+ mysql_mutex_unlock(&mutex);
if (UNIV_UNLIKELY(srv_shutdown_state > SRV_SHUTDOWN_INITIATED))
{
@@ -685,7 +684,7 @@ repeat:
group_commit_lock::ACQUIRED)
{
mysql_mutex_lock(&log_sys.mutex);
- write_lsn= log_sys.write_buf();
+ write_lsn= log_sys.write_buf<true>();
}
else
write_lsn= 0;
@@ -734,20 +733,21 @@ ATTRIBUTE_COLD void log_write_and_flush()
#ifdef HAVE_PMEM
if (log_sys.is_pmem())
{
- mysql_mutex_unlock(&log_sys.mutex);
lsn_t lsn{log_sys.get_lsn()};
log_sys.persist(lsn);
lsn= flush_lock.release(lsn);
if (lsn)
+ {
+ mysql_mutex_unlock(&log_sys.mutex);
log_write_up_to(lsn, true, &dummy_callback);
+ mysql_mutex_lock(&log_sys.mutex);
+ }
}
else
#endif
{
- const lsn_t write_lsn{log_sys.write_buf()};
- const lsn_t flush_lsn{log_flush(write_lock.value())};
- if (write_lsn || flush_lsn)
- log_write_up_to(std::max(write_lsn, flush_lsn), true, &dummy_callback);
+ log_sys.write_buf<false>();
+ log_flush(write_lock.value());
}
}
@@ -1112,7 +1112,6 @@ void log_t::close()
#endif
mysql_mutex_destroy(&mutex);
- mysql_mutex_destroy(&flush_order_mutex);
recv_sys.close();
diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
index 9dbe6704259..8063acb5395 100644
--- a/storage/innobase/mtr/mtr0mtr.cc
+++ b/storage/innobase/mtr/mtr0mtr.cc
@@ -406,13 +406,8 @@ void mtr_t::commit()
else
lsns= { m_commit_lsn, PAGE_FLUSH_NO };
- if (m_made_dirty)
- mysql_mutex_lock(&log_sys.flush_order_mutex);
-
- /* It is now safe to release log_sys.mutex because the
- buf_pool.flush_order_mutex will ensure that we are the first one
- to insert into buf_pool.flush_list. */
- mysql_mutex_unlock(&log_sys.mutex);
+ if (!m_made_dirty)
+ mysql_mutex_unlock(&log_sys.mutex);
if (m_freed_pages)
{
@@ -440,7 +435,7 @@ void mtr_t::commit()
(ReleaseBlocks(lsns.first, m_commit_lsn,
m_memo)));
if (m_made_dirty)
- mysql_mutex_unlock(&log_sys.flush_order_mutex);
+ mysql_mutex_unlock(&log_sys.mutex);
m_memo.for_each_block_in_reverse(CIterate<ReleaseLatches>());
@@ -517,9 +512,9 @@ void mtr_t::commit_shrink(fil_space_t &space)
const lsn_t start_lsn= finish_write(prepare_write()).first;
- mysql_mutex_lock(&log_sys.flush_order_mutex);
/* Durably write the reduced FSP_SIZE before truncating the data file. */
log_write_and_flush();
+ mysql_mutex_assert_owner(&log_sys.mutex);
os_file_truncate(space.chain.start->name, space.chain.start->handle,
os_offset_t{space.size} << srv_page_size_shift, true);
@@ -550,7 +545,7 @@ void mtr_t::commit_shrink(fil_space_t &space)
m_memo.for_each_block_in_reverse(CIterate<const ReleaseBlocks>
(ReleaseBlocks(start_lsn, m_commit_lsn,
m_memo)));
- mysql_mutex_unlock(&log_sys.flush_order_mutex);
+ mysql_mutex_unlock(&log_sys.mutex);
mysql_mutex_lock(&fil_system.mutex);
ut_ad(space.is_being_truncated);