skip_ckpt_after_rcv_on_stby_20120608_1.patch
text/x-patch
Filename: skip_ckpt_after_rcv_on_stby_20120608_1.patch
Type: text/x-patch
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 35 | 3 |
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 0f2678c..48c0cf6 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -6905,9 +6905,41 @@ StartupXLOG(void)
* allows some extra error checking in xlog_redo.
*/
if (bgwriterLaunched)
- RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
- CHECKPOINT_IMMEDIATE |
- CHECKPOINT_WAIT);
+ {
+ bool do_checkpoint = true;
+
+ if (WalRcvStarted())
+ {
+ /*
+ * This shutdown checkpoint on promotion should retards
+ * failover completion. In spite of the rule for TLI and
+ * shutdown checkpoint mentioned above, we want to skip this
+ * checkpoint securing recoveribility by crash recovery after
+ * this point.
+ */
+ uint32 replayEndId = 0;
+ uint32 replayEndSeg = 0;
+ XLogRecPtr replayEndRecPtr;
+ /* use volatile pointer to prevent code rearrangement */
+ volatile XLogCtlData *xlogctl = XLogCtl;
+
+ SpinLockAcquire(&xlogctl->info_lck);
+ replayEndRecPtr = xlogctl->replayEndRecPtr;
+ SpinLockRelease(&xlogctl->info_lck);
+ XLByteToSeg(replayEndRecPtr, replayEndId, replayEndSeg);
+ if (!XLogCheckpointNeeded(replayEndId, replayEndSeg))
+ {
+ do_checkpoint = false;
+ ereport(LOG,
+ (errmsg("Checkpoint on recovery end was skipped")));
+ }
+ }
+
+ if (do_checkpoint)
+ RequestCheckpoint(CHECKPOINT_END_OF_RECOVERY |
+ CHECKPOINT_IMMEDIATE |
+ CHECKPOINT_WAIT);
+ }
else
CreateCheckPoint(CHECKPOINT_END_OF_RECOVERY | CHECKPOINT_IMMEDIATE);