Commit 78e31f0a authored by Jan Lindström's avatar Jan Lindström

MDEV-6931: Page cleaner should do LRU flushing regardless of server activity

Merge Facebook commit 926a077b14b73c14094de7fc7aa913241b801b4d
authored by Inaam Rana from https://github.com/facebook/mysql-5.6.

This is fix for upstream bugs
http://bugs.mysql.com/bug.php?id=71988
http://bugs.mysql.com/bug.php?id=70500

page_cleaner should work whether or not there is server activity.
Its iterations become a noop when there is no work to do but we
should not tie it to the server activity.

The page_cleaner thread does spurious background flushing
because of conditional sleep between iterations. The solution
is not to make sleep dependent on server activity etc.
parent 7e71dfa9
......@@ -2411,25 +2411,16 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
while (srv_shutdown_state == SRV_SHUTDOWN_NONE) {
/* The page_cleaner skips sleep if the server is
idle and there are no pending IOs in the buffer pool
and there is work to do. */
if (srv_check_activity(last_activity)
|| buf_get_n_pending_read_ios()
|| n_flushed == 0) {
page_cleaner_sleep_if_needed(next_loop_time);
}
page_cleaner_sleep_if_needed(next_loop_time);
next_loop_time = ut_time_ms() + 1000;
if (srv_check_activity(last_activity)) {
last_activity = srv_get_activity_count();
/* Flush pages from end of LRU if required */
n_flushed = buf_flush_LRU_tail();
/* Flush pages from flush_list if required */
n_flushed += page_cleaner_flush_pages_if_needed();
page_cleaner_flush_pages_if_needed();
n_flushed = 0;
} else {
n_flushed = page_cleaner_do_flush_batch(
PCT_IO(100),
......@@ -2443,6 +2434,9 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
n_flushed);
}
}
/* Flush pages from end of LRU if required */
n_flushed = buf_flush_LRU_tail();
}
ut_ad(srv_shutdown_state > 0);
......
......@@ -2694,14 +2694,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
srv_current_thread_priority = srv_cleaner_thread_priority;
/* The page_cleaner skips sleep if the server is
idle and there are no pending IOs in the buffer pool
and there is work to do. */
if (srv_check_activity(last_activity)
|| buf_get_n_pending_read_ios()
|| n_flushed == 0) {
page_cleaner_sleep_if_needed(next_loop_time);
}
page_cleaner_sleep_if_needed(next_loop_time);
page_cleaner_sleep_time
= page_cleaner_adapt_flush_sleep_time();
......@@ -2709,6 +2702,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
next_loop_time = ut_time_ms() + page_cleaner_sleep_time;
server_active = srv_check_activity(last_activity);
if (server_active
|| ut_time_ms() - last_activity_time < 1000) {
......@@ -2719,7 +2713,8 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
}
/* Flush pages from flush_list if required */
n_flushed += page_cleaner_flush_pages_if_needed();
page_cleaner_flush_pages_if_needed();
n_flushed = 0;
} else {
n_flushed = page_cleaner_do_flush_batch(
PCT_IO(100),
......@@ -2733,6 +2728,9 @@ DECLARE_THREAD(buf_flush_page_cleaner_thread)(
n_flushed);
}
}
/* Flush pages from end of LRU if required */
n_flushed = buf_flush_LRU_tail();
}
ut_ad(srv_shutdown_state > 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment