提交 324a3aee 编写于 作者: A Ashwin Agrawal

Add checkpoint flag to convey RESYNC_TO_SYNC transition.

With commit 324653d3, we stopped performing checkpoint within filerep backend
process like Resyncmanager process. Instead started using RequestCheckpoint
mechanism to get teh job done by checkpoint process. Since CreateCheckpoint code
is also handling the resync_to_sync transition processing due to locking
constraints, need to modify the mechanism to convey the same to checkpoint
process. Hence adding flag so that ResyncManager process can convey to
checkpoint process to perform the transition actions. Without the change primary
segment would encounter fault and transition back to changetracking from resync
instead of moving to sync state.
上级 fc779e46
......@@ -8770,6 +8770,7 @@ CreateCheckPoint(int flags)
uint32 _logSeg;
TransactionId *inCommitXids;
int nInCommit;
bool resync_to_sync_transition = (flags & CHECKPOINT_RESYNC_TO_INSYNC_TRANSITION) != 0;
if (Debug_persistent_recovery_print)
{
......@@ -8784,7 +8785,7 @@ CreateCheckPoint(int flags)
#ifdef FAULT_INJECTOR
/* During resync checkpoint has to complete otherwise segment cannot transition into Sync state */
if (! FileRepResync_IsTransitionFromResyncToInSync())
if (! resync_to_sync_transition)
{
if (FaultInjector_InjectFaultIfSet(
Checkpoint,
......@@ -8813,7 +8814,7 @@ CreateCheckPoint(int flags)
MemSet(&CheckpointStats, 0, sizeof(CheckpointStats));
CheckpointStats.ckpt_start_t = GetCurrentTimestamp();
if (FileRepResync_IsTransitionFromResyncToInSync())
if (resync_to_sync_transition)
{
LWLockAcquire(MirroredLock, LW_EXCLUSIVE);
......@@ -8938,7 +8939,7 @@ CreateCheckPoint(int flags)
#endif
{
LWLockRelease(WALInsertLock);
if (FileRepResync_IsTransitionFromResyncToInSync())
if (resync_to_sync_transition)
{
LWLockRelease(MirroredLock);
}
......@@ -9310,7 +9311,7 @@ CreateCheckPoint(int flags)
XLogLocationToString(&ControlFile->checkPoint),
XLogLocationToString2(&checkPoint.redo));
if (FileRepResync_IsTransitionFromResyncToInSync())
if (resync_to_sync_transition)
{
RequestXLogSwitch();
......
......@@ -165,8 +165,6 @@ typedef struct FileRepResyncShmem_s {
volatile int appendOnlyCommitCount;
/* This counter is protected by FileRepAppendOnlyCommitCountLock */
bool checkpointRequest;
bool reMirrorAllowed;
/*
* This flag is used just to enable FILEREP proces to perform some operation
......@@ -362,14 +360,6 @@ FileRepResync_SetReMirrorAllowed(void)
fileRepResyncShmem->reMirrorAllowed = TRUE;
}
bool
FileRepResync_IsTransitionFromResyncToInSync(void)
{
return((fileRepResyncShmem != NULL)?
(fileRepResyncShmem->checkpointRequest == TRUE &&
fileRepProcessType == FileRepProcessTypeResyncManager):false);
}
bool
FileRepResync_IsReMirrorAllowed(void)
{
......@@ -505,8 +495,6 @@ FileRepResync_ShmemInit(void)
fileRepResyncShmem->appendOnlyCommitCount = 0;
fileRepResyncShmem->checkpointRequest = FALSE;
fileRepResyncShmem->reMirrorAllowed = FALSE;
fileRepResyncShmem->totalBlocksToSynchronize = 0;
......@@ -575,9 +563,6 @@ FileRepResync_ShmemReInit(void)
/*
* NOTE: Do not zero Commit Work Intent count for ReInit.
*/
fileRepResyncShmem->checkpointRequest = FALSE;
fileRepResyncShmem->reMirrorAllowed = FALSE;
fileRepResyncShmem->totalBlocksToSynchronize = 0;
......@@ -1291,9 +1276,7 @@ FileRepResyncManager_InSyncTransition(void)
MirroredFlatFile_DropFilesFromDir();
fileRepResyncShmem->checkpointRequest = TRUE;
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT);
fileRepResyncShmem->checkpointRequest = FALSE;
RequestCheckpoint(CHECKPOINT_IMMEDIATE | CHECKPOINT_FORCE | CHECKPOINT_WAIT | CHECKPOINT_RESYNC_TO_INSYNC_TRANSITION);
/*
* The second checkpoint is required in order to mirror pg_control
......
......@@ -208,6 +208,12 @@ extern bool XLOG_DEBUG;
/* These indicate the cause of a checkpoint request */
#define CHECKPOINT_CAUSE_XLOG 0x0010 /* XLOG consumption */
#define CHECKPOINT_CAUSE_TIME 0x0020 /* Elapsed time */
/*
* This falls in two categories, affects behavior of CreateCheckPoint and also
* indicates request is coming from ResyncManager process to switch primary
* segment from resync mode to sync mode.
*/
#define CHECKPOINT_RESYNC_TO_INSYNC_TRANSITION 0x0040
/* Checkpoint statistics */
typedef struct CheckpointStatsData
......
......@@ -85,8 +85,6 @@ extern int FileRepResync_DecAppendOnlyCommitCount(int count);
extern int FileRepResync_GetAppendOnlyCommitCount(void);
extern bool FileRepResync_IsTransitionFromResyncToInSync(void);
extern bool FileRepResync_IsReMirrorAllowed(void);
extern void FileRepResync_SetReMirrorAllowed(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册