diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2023-05-17 14:58:11 +0200 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2023-05-17 14:58:11 +0200 |
commit | 2543673dd22782f59299fd2e72179601892bd967 (patch) | |
tree | b73641bd88c9d1572203c75da618fce1937518e8 /storage/innobase/row/row0mysql.cc | |
parent | 4e5b771e980edfdad5c5414aa62c81d409d585a4 (diff) | |
parent | ef911553f442cbb1baaac2af44c38b54fd058c41 (diff) | |
download | mariadb-git-2543673dd22782f59299fd2e72179601892bd967.tar.gz |
Merge branch '11.0' into 11.1bb-11.1-release
Diffstat (limited to 'storage/innobase/row/row0mysql.cc')
-rw-r--r-- | storage/innobase/row/row0mysql.cc | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/storage/innobase/row/row0mysql.cc b/storage/innobase/row/row0mysql.cc index 81879431096..27f48c1a4de 100644 --- a/storage/innobase/row/row0mysql.cc +++ b/storage/innobase/row/row0mysql.cc @@ -66,17 +66,23 @@ Created 9/17/2000 Heikki Tuuri #include <thread> -/*******************************************************************//** -Delays an INSERT, DELETE or UPDATE operation if the purge is lagging. */ -static -void -row_mysql_delay_if_needed(void) -/*===========================*/ +/** Delay an INSERT, DELETE or UPDATE operation if the purge is lagging. */ +static void row_mysql_delay_if_needed() { - if (srv_dml_needed_delay) { - std::this_thread::sleep_for( - std::chrono::microseconds(srv_dml_needed_delay)); - } + const auto delay= srv_dml_needed_delay; + if (UNIV_UNLIKELY(delay != 0)) + { + /* Adjust for purge_coordinator_state::refresh() */ + log_sys.latch.rd_lock(SRW_LOCK_CALL); + const lsn_t last= log_sys.last_checkpoint_lsn, + max_age= log_sys.max_checkpoint_age; + log_sys.latch.rd_unlock(); + const lsn_t lsn= log_sys.get_lsn(); + if ((lsn - last) / 4 >= max_age / 5) + buf_flush_ahead(last + max_age / 5, false); + srv_wake_purge_thread_if_not_active(); + std::this_thread::sleep_for(std::chrono::microseconds(delay)); + } } /*******************************************************************//** |