summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2020-10-26 10:00:39 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2020-10-26 10:00:39 +0200
commitcdd97d8c2eaa892fdc4d26ea6652878aeceeb8d5 (patch)
tree0e43e0b5bf08e8a6155b3cebd6a20ddeb6cff040
parent8cd49b45d19f2b8749ddfa5cea283dcdb3302390 (diff)
downloadmariadb-git-bb-10.5-MDEV-23855.tar.gz
Amend 32ab5e10295b058a9a94aa8612393a9970e9812abb-10.5-MDEV-23855
Always wait log_flush_task to finish on shutdown.
-rw-r--r--storage/innobase/buf/buf0flu.cc44
-rw-r--r--storage/innobase/include/buf0flu.h5
-rw-r--r--storage/innobase/log/log0log.cc37
3 files changed, 48 insertions, 38 deletions
diff --git a/storage/innobase/buf/buf0flu.cc b/storage/innobase/buf/buf0flu.cc
index 40d505830c3..0b5e6cc0ea3 100644
--- a/storage/innobase/buf/buf0flu.cc
+++ b/storage/innobase/buf/buf0flu.cc
@@ -26,6 +26,7 @@ Created 11/11/1995 Heikki Tuuri
*******************************************************/
#include "univ.i"
+#include <my_service_manager.h>
#include <mysql/service_thd_wait.h>
#include <sql_class.h>
@@ -2171,7 +2172,7 @@ next:
}
/** Initialize page_cleaner. */
-void buf_flush_page_cleaner_init()
+ATTRIBUTE_COLD void buf_flush_page_cleaner_init()
{
ut_ad(!buf_page_cleaner_is_active);
ut_ad(srv_operation == SRV_OPERATION_NORMAL ||
@@ -2182,6 +2183,47 @@ void buf_flush_page_cleaner_init()
os_thread_create(buf_flush_page_cleaner);
}
+/** @return the number of dirty pages in the buffer pool */
+static ulint buf_flush_list_length()
+{
+ mysql_mutex_lock(&buf_pool.flush_list_mutex);
+ const ulint len= UT_LIST_GET_LEN(buf_pool.flush_list);
+ mysql_mutex_unlock(&buf_pool.flush_list_mutex);
+ return len;
+}
+
+/** Flush the buffer pool on shutdown. */
+ATTRIBUTE_COLD void buf_flush_buffer_pool()
+{
+ ut_ad(!buf_page_cleaner_is_active);
+ ut_ad(!buf_flush_sync_lsn);
+
+ service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
+ "Waiting to flush the buffer pool");
+
+ while (buf_pool.n_flush_list || buf_flush_list_length())
+ {
+ buf_flush_lists(srv_max_io_capacity, LSN_MAX);
+ timespec abstime;
+
+ if (buf_pool.n_flush_list)
+ {
+ service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
+ "Waiting to flush " ULINTPF " pages",
+ buf_flush_list_length());
+ set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2);
+ mysql_mutex_lock(&buf_pool.mutex);
+ while (buf_pool.n_flush_list)
+ mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex,
+ &abstime);
+ mysql_mutex_unlock(&buf_pool.mutex);
+ }
+ }
+
+ ut_ad(!buf_pool.any_io_pending());
+ log_flush_task.wait();
+}
+
/** Synchronously flush dirty blocks.
NOTE: The calling thread is not allowed to hold any buffer page latches! */
void buf_flush_sync()
diff --git a/storage/innobase/include/buf0flu.h b/storage/innobase/include/buf0flu.h
index dffca114b71..1dd0d35793b 100644
--- a/storage/innobase/include/buf0flu.h
+++ b/storage/innobase/include/buf0flu.h
@@ -123,11 +123,14 @@ buf_flush_note_modification(
set of mtr's */
/** Initialize page_cleaner. */
-void buf_flush_page_cleaner_init();
+ATTRIBUTE_COLD void buf_flush_page_cleaner_init();
/** Wait for pending flushes to complete. */
void buf_flush_wait_batch_end_acquiring_mutex(bool lru);
+/** Flush the buffer pool on shutdown. */
+ATTRIBUTE_COLD void buf_flush_buffer_pool();
+
#ifdef UNIV_DEBUG
/** Validate the flush list. */
void buf_flush_validate();
diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
index 95a38b1f20d..d2e85f7db61 100644
--- a/storage/innobase/log/log0log.cc
+++ b/storage/innobase/log/log0log.cc
@@ -986,41 +986,6 @@ ATTRIBUTE_COLD void log_check_margins()
extern void buf_resize_shutdown();
-/** @return the number of dirty pages in the buffer pool */
-static ulint flush_list_length()
-{
- mysql_mutex_lock(&buf_pool.flush_list_mutex);
- const ulint len= UT_LIST_GET_LEN(buf_pool.flush_list);
- mysql_mutex_unlock(&buf_pool.flush_list_mutex);
- return len;
-}
-
-static void flush_buffer_pool()
-{
- service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
- "Waiting to flush the buffer pool");
- while (buf_pool.n_flush_list || flush_list_length())
- {
- buf_flush_lists(srv_max_io_capacity, LSN_MAX);
- timespec abstime;
-
- if (buf_pool.n_flush_list)
- {
- service_manager_extend_timeout(INNODB_EXTEND_TIMEOUT_INTERVAL,
- "Waiting to flush " ULINTPF " pages",
- flush_list_length());
- set_timespec(abstime, INNODB_EXTEND_TIMEOUT_INTERVAL / 2);
- mysql_mutex_lock(&buf_pool.mutex);
- while (buf_pool.n_flush_list)
- mysql_cond_timedwait(&buf_pool.done_flush_list, &buf_pool.mutex,
- &abstime);
- mysql_mutex_unlock(&buf_pool.mutex);
- }
- }
-
- ut_ad(!buf_pool.any_io_pending());
-}
-
/** Make a checkpoint at the latest lsn on shutdown. */
ATTRIBUTE_COLD void logs_empty_and_mark_files_at_shutdown()
{
@@ -1141,7 +1106,7 @@ wait_suspend_loop:
goto loop;
} else {
- flush_buffer_pool();
+ buf_flush_buffer_pool();
}
if (log_sys.is_initialised()) {