*** a/src/backend/access/transam/xlog.c --- b/src/backend/access/transam/xlog.c *************** *** 7084,7094 **** CreateCheckPoint(int flags) CHECKPOINT_FORCE)) == 0) { XLogRecPtr curInsert; INSERT_RECPTR(curInsert, Insert, Insert->curridx); if (curInsert == ControlFile->checkPoint + MAXALIGN(SizeOfXLogRecord + sizeof(CheckPoint)) && ! ControlFile->checkPoint == ControlFile->checkPointCopy.redo) { LWLockRelease(WALInsertLock); LWLockRelease(CheckpointLock); --- 7084,7110 ---- CHECKPOINT_FORCE)) == 0) { XLogRecPtr curInsert; + uint32 runningXactXLog = 0; + /* + * Take the size of RUNNING XACT XLOG, only if HOT STANDBY is enabled. + * Because if it is not enabled, then RUNNING XACT XLOG is not logged. + */ + if (!shutdown && XLogStandbyInfoActive()) + { + runningXactXLog = MAXALIGN(MinSizeOfXactRunningXacts) + SizeOfXLogRecord; + } + + /* + * ControlFile->checkPointCopy.redo points to the offset before + * RUNNING XACT XLOG was inserted but ControlFile->checkPoint + * points to the offset after insertion, so we should add size of RUNNING XACT XLOG + * to check if any other new XLOG has been inserted + */ INSERT_RECPTR(curInsert, Insert, Insert->curridx); if (curInsert == ControlFile->checkPoint + MAXALIGN(SizeOfXLogRecord + sizeof(CheckPoint)) && ! ControlFile->checkPoint == ControlFile->checkPointCopy.redo + runningXactXLog) { LWLockRelease(WALInsertLock); LWLockRelease(CheckpointLock);