diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc index b497e4f84e8..9426d140e71 100644 --- a/storage/innobase/buf/buf0flu.cc +++ b/storage/innobase/buf/buf0flu.cc @@ -28,6 +28,7 @@ Created 11/11/1995 Heikki Tuuri #include "ha_prototypes.h" #include #include +#include #include "buf0flu.h" #include "buf0buf.h" @@ -2690,21 +2691,21 @@ than a second @retval OS_SYNC_TIME_EXCEEDED if timeout was exceeded @param next_loop_time time when next loop iteration should start @param sig_count zero or the value returned by previous call of - os_event_reset() */ + os_event_reset() +@param cur_time current time as in ut_time_ms() */ static ulint pc_sleep_if_needed( /*===============*/ ulint next_loop_time, - int64_t sig_count) + int64_t sig_count, + ulint cur_time) { /* No sleep if we are cleaning the buffer pool during the shutdown with everything else finished */ if (srv_shutdown_state == SRV_SHUTDOWN_FLUSH_PHASE) return OS_SYNC_TIME_EXCEEDED; - ulint cur_time = ut_time_ms(); - if (next_loop_time > cur_time) { /* Get sleep interval in micro seconds. We use ut_min() to avoid long sleep in case of wrap around. */ @@ -3200,6 +3201,7 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*) ulint last_pages = 0; while (srv_shutdown_state == SRV_SHUTDOWN_NONE) { + ulint curr_time = ut_time_ms(); /* The page_cleaner skips sleep if the server is idle and there are no pending IOs in the buffer pool @@ -3209,23 +3211,22 @@ DECLARE_THREAD(buf_flush_page_cleaner_coordinator)(void*) || n_flushed == 0) { ret_sleep = pc_sleep_if_needed( - next_loop_time, sig_count); - - if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { - break; - } - } else if (ut_time_ms() > next_loop_time) { + next_loop_time, sig_count, curr_time); + } else if (curr_time > next_loop_time) { ret_sleep = OS_SYNC_TIME_EXCEEDED; } else { ret_sleep = 0; } + if (srv_shutdown_state != SRV_SHUTDOWN_NONE) { + break; + } + sig_count = os_event_reset(buf_flush_event); if (ret_sleep == OS_SYNC_TIME_EXCEEDED) { - ulint curr_time = ut_time_ms(); - - if (curr_time > next_loop_time + 3000 + if (global_system_variables.log_warnings > 2 + && curr_time > next_loop_time + 3000 && !(test_flags & TEST_SIGINT)) { if (warn_count == 0) { ib::info() << "page_cleaner: 1000ms"