From 3ff702339d12e59805961ce32832904681aafe50 Mon Sep 17 00:00:00 2001 From: Haoyu Huang Date: Mon, 15 Sep 2025 22:03:52 +0000 Subject: [PATCH 1/2] c --- src/backend/access/transam/xlog.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a860563c1dd..d2737b75962 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7222,10 +7222,18 @@ CreateRestartPoint(int flags) ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY; UpdateControlFile(); LWLockRelease(ControlFileLock); + // Flush dirty buffers. + CheckPointBuffers(flags); } return false; } + if (flags & CHECKPOINT_IS_SHUTDOWN) + { + // Flush dirty buffers. + CheckPointBuffers(flags); + } + /* * Update the shared RedoRecPtr so that the startup process can calculate * the number of segments replayed since last restartpoint, and request a From ed0049c533c8696d02480307cc0608235904228b Mon Sep 17 00:00:00 2001 From: Haoyu Huang Date: Tue, 16 Sep 2025 21:34:51 +0000 Subject: [PATCH 2/2] c --- src/backend/access/transam/xlog.c | 12 +++++++----- src/include/access/xlog.h | 3 +++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d2737b75962..825e5604ff3 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -153,6 +153,7 @@ restore_running_xacts_callback_t restore_running_xacts_callback; set_lwlsn_db_hook_type set_lwlsn_db_hook = NULL; set_lwlsn_relation_hook_type set_lwlsn_relation_hook = NULL; set_max_lwlsn_hook_type set_max_lwlsn_hook = NULL; +flush_dirty_buffers_hook_type flush_dirty_buffers_hook = NULL; /* * Number of WAL insertion locks to use. A higher value allows more insertions @@ -7222,16 +7223,17 @@ CreateRestartPoint(int flags) ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY; UpdateControlFile(); LWLockRelease(ControlFileLock); - // Flush dirty buffers. - CheckPointBuffers(flags); + if (flush_dirty_buffers_hook) + { + flush_dirty_buffers_hook(flags); + } } return false; } - if (flags & CHECKPOINT_IS_SHUTDOWN) + if (flush_dirty_buffers_hook) { - // Flush dirty buffers. - CheckPointBuffers(flags); + flush_dirty_buffers_hook(flags); } /* diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index dae5e665eb9..8ecf727f4e3 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -270,6 +270,9 @@ extern set_lwlsn_db_hook_type set_lwlsn_db_hook; extern set_lwlsn_relation_hook_type set_lwlsn_relation_hook; extern set_max_lwlsn_hook_type set_max_lwlsn_hook; +typedef void (*flush_dirty_buffers_hook_type)(int flags); +extern flush_dirty_buffers_hook_type flush_dirty_buffers_hook; + extern void SetRedoStartLsn(XLogRecPtr RedoStartLSN); extern XLogRecPtr GetRedoStartLsn(void);