!254 Fixed the problem that cannot stop the standby node.

Merge pull request !254 from Cross-罗/master
This commit is contained in:
opengauss-bot
2020-09-28 09:46:11 +08:00
committed by Gitee
2 changed files with 19 additions and 0 deletions

View File

@ -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);

View File

@ -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;