summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2021-03-09 09:51:20 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2021-03-09 09:51:20 +0200
commit1433bc4cb467c202f930f154cb194888bfa4a6fb (patch)
tree1ca540e5a937821d59f0af94d0c8c5d985d7e1c1
parent7ecee0c35af8085a8730fce9f2f5917c65406bb0 (diff)
downloadmariadb-git-1433bc4cb467c202f930f154cb194888bfa4a6fb.tar.gz
fixup 7ecee0c35af8085a8730fce9f2f5917c65406bb0bb-10.5-MDEV-24949
Ensure that the page cleaner will be woken up even if the server becomes idle again.
-rw-r--r--storage/innobase/buf/buf0flu.cc20
-rw-r--r--storage/innobase/include/buf0buf.h28
2 files changed, 40 insertions, 8 deletions
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 5357a2d0500..c73ddd9802d 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -134,8 +134,15 @@ inline void buf_pool_t::page_cleaner_wakeup()
double dirty_pct= double(UT_LIST_GET_LEN(buf_pool.flush_list)) * 100.0 /
double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free));
double pct_lwm= srv_max_dirty_pages_pct_lwm;
- if ((pct_lwm != 0.0 && pct_lwm <= dirty_pct) ||
- srv_max_buf_pool_modified_pct <= dirty_pct)
+
+ /* Wake up the buf_flush_page_cleaner thread if:
+ (1) innodb_max_dirty_pages_pct is exceeded, or
+ (2) innodb_max_dirty_pages_pct_lwm is nonzero and exceeded, or
+ (3) innodb_max_dirty_pages_pct_lwm is nonzero and the server is idle */
+ if (srv_max_buf_pool_modified_pct <= dirty_pct ||
+ (pct_lwm != 0.0 &&
+ (pct_lwm <= dirty_pct ||
+ srv_get_activity_count() == buf_pool.get_activity_count())))
{
page_cleaner_is_idle= false;
pthread_cond_signal(&do_flush_list);
@@ -2069,12 +2076,12 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
" See the man page of setpriority().";
#endif /* UNIV_LINUX */
- auto last_activity_count= srv_get_activity_count();
ulint last_pages= 0;
timespec abstime;
set_timespec(abstime, 1);
mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ buf_pool.set_activity_count(srv_get_activity_count());
lsn_t lsn_limit;
@@ -2146,12 +2153,9 @@ unemployed:
/* We enable idle flushing if the server is not performing
trx_t::commit() of write transactions. */
idle_flush= dirty_pct < srv_max_dirty_pages_pct_lwm;
- const auto activity_count= srv_get_activity_count();
- if (idle_flush && activity_count != last_activity_count)
- {
- last_activity_count= activity_count;
+ if (idle_flush &&
+ !buf_pool.update_activity_count(srv_get_activity_count()))
goto unemployed;
- }
}
else if (dirty_pct < srv_max_buf_pool_modified_pct)
goto unemployed;
diff --git a/storage/innobase/include/buf0buf.h b/storage/innobase/include/buf0buf.h
index 12fb139f1bf..7637aa54648 100644
--- a/storage/innobase/include/buf0buf.h
+++ b/storage/innobase/include/buf0buf.h
@@ -1946,6 +1946,8 @@ public:
private:
/** whether the page cleaner needs wakeup from indefinite sleep */
bool page_cleaner_is_idle;
+ /** srv_activity_count() observed by the page cleaner */
+ ulint last_activity_count;
public:
/** signalled to wake up the page_cleaner; protected by flush_list_mutex */
pthread_cond_t do_flush_list;
@@ -1966,6 +1968,32 @@ public:
page_cleaner_is_idle= deep_sleep;
}
+ /** Initialize the activity count observed by the page cleaner */
+ void set_activity_count(ulint activity_count)
+ {
+ mysql_mutex_assert_owner(&flush_list_mutex);
+ last_activity_count= activity_count;
+ }
+
+ /** @return the activity count observed by the page cleaner */
+ ulint get_activity_count() const
+ {
+ mysql_mutex_assert_owner(&flush_list_mutex);
+ return last_activity_count;
+ }
+
+ /** Update server activity count
+ @param activity_count srv_get_activity_count()
+ @return whether the activity count differed from the previous one */
+ bool update_activity_count(ulint activity_count)
+ {
+ mysql_mutex_assert_owner(&flush_list_mutex);
+ if (last_activity_count == activity_count)
+ return false;
+ last_activity_count= activity_count;
+ return true;
+ }
+
// n_flush_LRU + n_flush_list is approximately COUNT(io_fix()==BUF_IO_WRITE)
// in flush_list