diff --git a/src/gausskernel/storage/access/transam/xlog.cpp b/src/gausskernel/storage/access/transam/xlog.cpp index 3502d592d..21bbcf746 100755 --- a/src/gausskernel/storage/access/transam/xlog.cpp +++ b/src/gausskernel/storage/access/transam/xlog.cpp @@ -10776,6 +10776,23 @@ bool IsRestartPointSafe(const XLogRecPtr checkPoint) return true; } +void wait_all_dirty_page_flush(int flags, XLogRecPtr redo) +{ + /* need wait all dirty page finish flush */ + if (g_instance.attr.attr_storage.enableIncrementalCheckpoint) { + update_dirty_page_queue_rec_lsn(redo, true); + g_instance.ckpt_cxt_ctl->full_ckpt_redo_ptr = redo; + g_instance.ckpt_cxt_ctl->full_ckpt_expected_flush_loc = get_dirty_page_queue_tail(); + pg_write_barrier(); + if (get_dirty_page_num() > 0) { + g_instance.ckpt_cxt_ctl->flush_all_dirty_page = true; + ereport(LOG, (errmsg("CreateRestartPoint, need flush %ld pages.", get_dirty_page_num()))); + CheckPointBuffers(flags, true); + } + } + return; +} + /* * Establish a restartpoint if possible. * @@ -10848,6 +10865,7 @@ bool CreateRestartPoint(int flags) UpdateMinRecoveryPoint(InvalidXLogRecPtr, true); if ((unsigned int)flags & CHECKPOINT_IS_SHUTDOWN) { + wait_all_dirty_page_flush(flags, lastCheckPoint.redo); LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); t_thrd.shemem_ptr_cxt.ControlFile->state = DB_SHUTDOWNED_IN_RECOVERY; t_thrd.shemem_ptr_cxt.ControlFile->time = (pg_time_t)time(NULL); diff --git a/src/include/knl/knl_instance.h b/src/include/knl/knl_instance.h index edac6dfd4..b1a2bf0e6 100644 --- a/src/include/knl/knl_instance.h +++ b/src/include/knl/knl_instance.h @@ -337,6 +337,7 @@ typedef struct knl_g_ckpt_context { volatile bool flush_all_dirty_page; volatile bool buffers_contain_hashbucket; volatile uint64 full_ckpt_expected_flush_loc; + volatile XLogRecPtr full_ckpt_redo_ptr; volatile uint32 current_page_writer_count; volatile XLogRecPtr page_writer_xlog_flush_loc; volatile LWLock *backend_wait_lock;