diff options
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r-- | src/backend/access/transam/clog.c | 12 | ||||
-rw-r--r-- | src/backend/access/transam/commit_ts.c | 8 | ||||
-rw-r--r-- | src/backend/access/transam/subtrans.c | 14 | ||||
-rw-r--r-- | src/backend/access/transam/twophase.c | 109 | ||||
-rw-r--r-- | src/backend/access/transam/varsup.c | 2 | ||||
-rw-r--r-- | src/backend/access/transam/xact.c | 9 | ||||
-rw-r--r-- | src/backend/access/transam/xlog.c | 112 | ||||
-rw-r--r-- | src/backend/access/transam/xlogfuncs.c | 5 | ||||
-rw-r--r-- | src/backend/access/transam/xloginsert.c | 23 | ||||
-rw-r--r-- | src/backend/access/transam/xlogreader.c | 4 | ||||
-rw-r--r-- | src/backend/access/transam/xlogutils.c | 57 |
11 files changed, 183 insertions, 172 deletions
diff --git a/src/backend/access/transam/clog.c b/src/backend/access/transam/clog.c index 7a007a6ba50..bece57589e8 100644 --- a/src/backend/access/transam/clog.c +++ b/src/backend/access/transam/clog.c @@ -84,7 +84,7 @@ static int ZeroCLOGPage(int pageno, bool writeXlog); static bool CLOGPagePrecedes(int page1, int page2); static void WriteZeroPageXlogRec(int pageno); static void WriteTruncateXlogRec(int pageno, TransactionId oldestXact, - Oid oldestXidDb); + Oid oldestXidDb); static void TransactionIdSetPageStatus(TransactionId xid, int nsubxids, TransactionId *subxids, XidStatus status, XLogRecPtr lsn, int pageno); @@ -680,13 +680,13 @@ TruncateCLOG(TransactionId oldestXact, Oid oldestxid_datoid) /* vac_truncate_clog already advanced oldestXid */ Assert(TransactionIdPrecedesOrEquals(oldestXact, - ShmemVariableCache->oldestXid)); + ShmemVariableCache->oldestXid)); /* - * Write XLOG record and flush XLOG to disk. We record the oldest xid we're - * keeping information about here so we can ensure that it's always ahead - * of clog truncation in case we crash, and so a standby finds out the new - * valid xid before the next checkpoint. + * Write XLOG record and flush XLOG to disk. We record the oldest xid + * we're keeping information about here so we can ensure that it's always + * ahead of clog truncation in case we crash, and so a standby finds out + * the new valid xid before the next checkpoint. */ WriteTruncateXlogRec(cutoffPage, oldestXact, oldestxid_datoid); diff --git a/src/backend/access/transam/commit_ts.c b/src/backend/access/transam/commit_ts.c index 03ffa209084..7646c23c4e7 100644 --- a/src/backend/access/transam/commit_ts.c +++ b/src/backend/access/transam/commit_ts.c @@ -748,8 +748,8 @@ ShutdownCommitTs(void) SimpleLruFlush(CommitTsCtl, false); /* - * fsync pg_commit_ts to ensure that any files flushed previously are durably - * on disk. + * fsync pg_commit_ts to ensure that any files flushed previously are + * durably on disk. */ fsync_fname("pg_commit_ts", true); } @@ -764,8 +764,8 @@ CheckPointCommitTs(void) SimpleLruFlush(CommitTsCtl, true); /* - * fsync pg_commit_ts to ensure that any files flushed previously are durably - * on disk. + * fsync pg_commit_ts to ensure that any files flushed previously are + * durably on disk. */ fsync_fname("pg_commit_ts", true); } diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c index cc68484a5d6..cef03f83e03 100644 --- a/src/backend/access/transam/subtrans.c +++ b/src/backend/access/transam/subtrans.c @@ -87,9 +87,9 @@ SubTransSetParent(TransactionId xid, TransactionId parent) ptr += entryno; /* - * It's possible we'll try to set the parent xid multiple times - * but we shouldn't ever be changing the xid from one valid xid - * to another valid xid, which would corrupt the data structure. + * It's possible we'll try to set the parent xid multiple times but we + * shouldn't ever be changing the xid from one valid xid to another valid + * xid, which would corrupt the data structure. */ if (*ptr != parent) { @@ -162,13 +162,13 @@ SubTransGetTopmostTransaction(TransactionId xid) parentXid = SubTransGetParent(parentXid); /* - * By convention the parent xid gets allocated first, so should - * always precede the child xid. Anything else points to a corrupted - * data structure that could lead to an infinite loop, so exit. + * By convention the parent xid gets allocated first, so should always + * precede the child xid. Anything else points to a corrupted data + * structure that could lead to an infinite loop, so exit. */ if (!TransactionIdPrecedes(parentXid, previousXid)) elog(ERROR, "pg_subtrans contains invalid entry: xid %u points to parent xid %u", - previousXid, parentXid); + previousXid, parentXid); } Assert(TransactionIdIsValid(previousXid)); diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 7bf2555af22..c50f9c4bf65 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -166,7 +166,7 @@ typedef struct GlobalTransactionData */ XLogRecPtr prepare_start_lsn; /* XLOG offset of prepare record start */ XLogRecPtr prepare_end_lsn; /* XLOG offset of prepare record end */ - TransactionId xid; /* The GXACT id */ + TransactionId xid; /* The GXACT id */ Oid owner; /* ID of user that executed the xact */ BackendId locking_backend; /* backend currently working on the xact */ @@ -220,11 +220,11 @@ static void RemoveGXact(GlobalTransaction gxact); static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len); static char *ProcessTwoPhaseBuffer(TransactionId xid, - XLogRecPtr prepare_start_lsn, - bool fromdisk, bool setParent, bool setNextXid); + XLogRecPtr prepare_start_lsn, + bool fromdisk, bool setParent, bool setNextXid); static void MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, - const char *gid, TimestampTz prepared_at, Oid owner, - Oid databaseid); + const char *gid, TimestampTz prepared_at, Oid owner, + Oid databaseid); static void RemoveTwoPhaseFile(TransactionId xid, bool giveWarning); static void RecreateTwoPhaseFile(TransactionId xid, void *content, int len); @@ -1304,7 +1304,7 @@ XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"), - errdetail("Failed while allocating a WAL reading processor."))); + errdetail("Failed while allocating a WAL reading processor."))); record = XLogReadRecord(xlogreader, lsn, &errormsg); if (record == NULL) @@ -1318,9 +1318,9 @@ XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len) (XLogRecGetInfo(xlogreader) & XLOG_XACT_OPMASK) != XLOG_XACT_PREPARE) ereport(ERROR, (errcode_for_file_access(), - errmsg("expected two-phase state data is not present in WAL at %X/%X", - (uint32) (lsn >> 32), - (uint32) lsn))); + errmsg("expected two-phase state data is not present in WAL at %X/%X", + (uint32) (lsn >> 32), + (uint32) lsn))); if (len != NULL) *len = XLogRecGetDataLen(xlogreader); @@ -1675,7 +1675,10 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon) LWLockAcquire(TwoPhaseStateLock, LW_SHARED); for (i = 0; i < TwoPhaseState->numPrepXacts; i++) { - /* Note that we are using gxact not pgxact so this works in recovery also */ + /* + * Note that we are using gxact not pgxact so this works in recovery + * also + */ GlobalTransaction gxact = TwoPhaseState->prepXacts[i]; if ((gxact->valid || gxact->inredo) && @@ -1727,8 +1730,8 @@ CheckPointTwoPhase(XLogRecPtr redo_horizon) void restoreTwoPhaseData(void) { - DIR *cldir; - struct dirent *clde; + DIR *cldir; + struct dirent *clde; cldir = AllocateDir(TWOPHASE_DIR); while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL) @@ -1801,8 +1804,8 @@ PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p) xid = gxact->xid; buf = ProcessTwoPhaseBuffer(xid, - gxact->prepare_start_lsn, - gxact->ondisk, false, true); + gxact->prepare_start_lsn, + gxact->ondisk, false, true); if (buf == NULL) continue; @@ -1876,8 +1879,8 @@ StandbyRecoverPreparedTransactions(void) xid = gxact->xid; buf = ProcessTwoPhaseBuffer(xid, - gxact->prepare_start_lsn, - gxact->ondisk, false, false); + gxact->prepare_start_lsn, + gxact->ondisk, false, false); if (buf != NULL) pfree(buf); } @@ -1920,17 +1923,17 @@ RecoverPreparedTransactions(void) xid = gxact->xid; /* - * Reconstruct subtrans state for the transaction --- needed - * because pg_subtrans is not preserved over a restart. Note that - * we are linking all the subtransactions directly to the - * top-level XID; there may originally have been a more complex - * hierarchy, but there's no need to restore that exactly. - * It's possible that SubTransSetParent has been set before, if - * the prepared transaction generated xid assignment records. + * Reconstruct subtrans state for the transaction --- needed because + * pg_subtrans is not preserved over a restart. Note that we are + * linking all the subtransactions directly to the top-level XID; + * there may originally have been a more complex hierarchy, but + * there's no need to restore that exactly. It's possible that + * SubTransSetParent has been set before, if the prepared transaction + * generated xid assignment records. */ buf = ProcessTwoPhaseBuffer(xid, - gxact->prepare_start_lsn, - gxact->ondisk, true, false); + gxact->prepare_start_lsn, + gxact->ondisk, true, false); if (buf == NULL) continue; @@ -1949,9 +1952,8 @@ RecoverPreparedTransactions(void) bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage)); /* - * Recreate its GXACT and dummy PGPROC. But, check whether - * it was added in redo and already has a shmem entry for - * it. + * Recreate its GXACT and dummy PGPROC. But, check whether it was + * added in redo and already has a shmem entry for it. */ LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE); MarkAsPreparingGuts(gxact, xid, gid, @@ -1980,9 +1982,8 @@ RecoverPreparedTransactions(void) StandbyReleaseLockTree(xid, hdr->nsubxacts, subxids); /* - * We're done with recovering this transaction. Clear - * MyLockedGxact, like we do in PrepareTransaction() during normal - * operation. + * We're done with recovering this transaction. Clear MyLockedGxact, + * like we do in PrepareTransaction() during normal operation. */ PostPrepare_Twophase(); @@ -2049,8 +2050,8 @@ ProcessTwoPhaseBuffer(TransactionId xid, else { ereport(WARNING, - (errmsg("removing future two-phase state from memory for \"%u\"", - xid))); + (errmsg("removing future two-phase state from memory for \"%u\"", + xid))); PrepareRedoRemove(xid, true); } return NULL; @@ -2063,8 +2064,8 @@ ProcessTwoPhaseBuffer(TransactionId xid, if (buf == NULL) { ereport(WARNING, - (errmsg("removing corrupt two-phase state file for \"%u\"", - xid))); + (errmsg("removing corrupt two-phase state file for \"%u\"", + xid))); RemoveTwoPhaseFile(xid, true); return NULL; } @@ -2082,15 +2083,15 @@ ProcessTwoPhaseBuffer(TransactionId xid, if (fromdisk) { ereport(WARNING, - (errmsg("removing corrupt two-phase state file for \"%u\"", - xid))); + (errmsg("removing corrupt two-phase state file for \"%u\"", + xid))); RemoveTwoPhaseFile(xid, true); } else { ereport(WARNING, - (errmsg("removing corrupt two-phase state from memory for \"%u\"", - xid))); + (errmsg("removing corrupt two-phase state from memory for \"%u\"", + xid))); PrepareRedoRemove(xid, true); } pfree(buf); @@ -2098,8 +2099,8 @@ ProcessTwoPhaseBuffer(TransactionId xid, } /* - * Examine subtransaction XIDs ... they should all follow main - * XID, and they may force us to advance nextXid. + * Examine subtransaction XIDs ... they should all follow main XID, and + * they may force us to advance nextXid. */ subxids = (TransactionId *) (buf + MAXALIGN(sizeof(TwoPhaseFileHeader)) + @@ -2122,7 +2123,7 @@ ProcessTwoPhaseBuffer(TransactionId xid, */ LWLockAcquire(XidGenLock, LW_EXCLUSIVE); if (TransactionIdFollowsOrEquals(subxid, - ShmemVariableCache->nextXid)) + ShmemVariableCache->nextXid)) { ShmemVariableCache->nextXid = subxid; TransactionIdAdvance(ShmemVariableCache->nextXid); @@ -2175,14 +2176,15 @@ RecordTransactionCommitPrepared(TransactionId xid, MyPgXact->delayChkpt = true; /* - * Emit the XLOG commit record. Note that we mark 2PC commits as potentially - * having AccessExclusiveLocks since we don't know whether or not they do. + * Emit the XLOG commit record. Note that we mark 2PC commits as + * potentially having AccessExclusiveLocks since we don't know whether or + * not they do. */ recptr = XactLogCommitRecord(committs, nchildren, children, nrels, rels, ninvalmsgs, invalmsgs, initfileinval, false, - MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, + MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, xid); @@ -2260,13 +2262,14 @@ RecordTransactionAbortPrepared(TransactionId xid, START_CRIT_SECTION(); /* - * Emit the XLOG commit record. Note that we mark 2PC aborts as potentially - * having AccessExclusiveLocks since we don't know whether or not they do. + * Emit the XLOG commit record. Note that we mark 2PC aborts as + * potentially having AccessExclusiveLocks since we don't know whether or + * not they do. */ recptr = XactLogAbortRecord(GetCurrentTimestamp(), nchildren, children, nrels, rels, - MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, + MyXactFlags | XACT_FLAGS_ACQUIREDACCESSEXCLUSIVELOCK, xid); /* Always flush, since we're about to remove the 2PC state file */ @@ -2301,8 +2304,8 @@ void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn) { TwoPhaseFileHeader *hdr = (TwoPhaseFileHeader *) buf; - char *bufptr; - const char *gid; + char *bufptr; + const char *gid; GlobalTransaction gxact; Assert(RecoveryInProgress()); @@ -2315,8 +2318,8 @@ PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn) * * This creates a gxact struct and puts it into the active array. * - * In redo, this struct is mainly used to track PREPARE/COMMIT entries - * in shared memory. Hence, we only fill up the bare minimum contents here. + * In redo, this struct is mainly used to track PREPARE/COMMIT entries in + * shared memory. Hence, we only fill up the bare minimum contents here. * The gxact also gets marked with gxact->inredo set to true to indicate * that it got added in the redo phase */ @@ -2340,7 +2343,7 @@ PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn) gxact->locking_backend = InvalidBackendId; gxact->valid = false; gxact->ondisk = XLogRecPtrIsInvalid(start_lsn); - gxact->inredo = true; /* yes, added in redo */ + gxact->inredo = true; /* yes, added in redo */ strcpy(gxact->gid, gid); /* And insert it into the active array */ diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 5efbfbd3d61..b02dd6fbd25 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -272,7 +272,7 @@ AdvanceOldestClogXid(TransactionId oldest_datfrozenxid) { LWLockAcquire(CLogTruncationLock, LW_EXCLUSIVE); if (TransactionIdPrecedes(ShmemVariableCache->oldestClogXid, - oldest_datfrozenxid)) + oldest_datfrozenxid)) { ShmemVariableCache->oldestClogXid = oldest_datfrozenxid; } diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index a3ff1b22f07..7e8c598f2ad 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -115,7 +115,7 @@ TransactionId *ParallelCurrentXids; * globally accessible, so can be set from anywhere in the code that requires * recording flags. */ -int MyXactFlags; +int MyXactFlags; /* * transaction states - transaction state from server perspective @@ -2641,7 +2641,8 @@ CleanupTransaction(void) * do abort cleanup processing */ AtCleanup_Portals(); /* now safe to release portal memory */ - AtEOXact_Snapshot(false, true); /* and release the transaction's snapshots */ + AtEOXact_Snapshot(false, true); /* and release the transaction's + * snapshots */ CurrentResourceOwner = NULL; /* and resource owner */ if (TopTransactionResourceOwner) @@ -5646,8 +5647,8 @@ xact_redo(XLogReaderState *record) else if (info == XLOG_XACT_PREPARE) { /* - * Store xid and start/end pointers of the WAL record in - * TwoPhaseState gxact entry. + * Store xid and start/end pointers of the WAL record in TwoPhaseState + * gxact entry. */ PrepareRedoAdd(XLogRecGetData(record), record->ReadRecPtr, diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index b98e37e1d38..399822d3fea 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -550,13 +550,12 @@ typedef struct XLogCtlInsert bool fullPageWrites; /* - * exclusiveBackupState indicates the state of an exclusive backup - * (see comments of ExclusiveBackupState for more details). - * nonExclusiveBackups is a counter indicating the number of streaming - * base backups currently in progress. forcePageWrites is set to true - * when either of these is non-zero. lastBackupStart is the latest - * checkpoint redo location used as a starting point for an online - * backup. + * exclusiveBackupState indicates the state of an exclusive backup (see + * comments of ExclusiveBackupState for more details). nonExclusiveBackups + * is a counter indicating the number of streaming base backups currently + * in progress. forcePageWrites is set to true when either of these is + * non-zero. lastBackupStart is the latest checkpoint redo location used + * as a starting point for an online backup. */ ExclusiveBackupState exclusiveBackupState; int nonExclusiveBackups; @@ -1082,7 +1081,7 @@ XLogInsertRecord(XLogRecData *rdata, */ if ((flags & XLOG_MARK_UNIMPORTANT) == 0) { - int lockno = holdingAllLocks ? 0 : MyLockNo; + int lockno = holdingAllLocks ? 0 : MyLockNo; WALInsertLocks[lockno].l.lastImportantAt = StartPos; } @@ -1405,7 +1404,8 @@ checkXLogConsistency(XLogReaderState *record) /* * If the block LSN is already ahead of this WAL record, we can't - * expect contents to match. This can happen if recovery is restarted. + * expect contents to match. This can happen if recovery is + * restarted. */ if (PageGetLSN(replay_image_masked) > record->EndRecPtr) continue; @@ -4975,15 +4975,15 @@ BootStrapXLOG(void) sysidentifier |= getpid() & 0xFFF; /* - * Generate a random nonce. This is used for authentication requests - * that will fail because the user does not exist. The nonce is used to - * create a genuine-looking password challenge for the non-existent user, - * in lieu of an actual stored password. + * Generate a random nonce. This is used for authentication requests that + * will fail because the user does not exist. The nonce is used to create + * a genuine-looking password challenge for the non-existent user, in lieu + * of an actual stored password. */ if (!pg_backend_random(mock_auth_nonce, MOCK_AUTH_NONCE_LEN)) ereport(PANIC, - (errcode(ERRCODE_INTERNAL_ERROR), - errmsg("could not generate secret authorization token"))); + (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("could not generate secret authorization token"))); /* First timeline ID is always 1 */ ThisTimeLineID = 1; @@ -5298,7 +5298,7 @@ readRecoveryCommandFile(void) DatumGetLSN(DirectFunctionCall3(pg_lsn_in, CStringGetDatum(item->value), ObjectIdGetDatum(InvalidOid), - Int32GetDatum(-1))); + Int32GetDatum(-1))); ereport(DEBUG2, (errmsg_internal("recovery_target_lsn = '%X/%X'", (uint32) (recoveryTargetLSN >> 32), @@ -5643,9 +5643,9 @@ recoveryStopsBefore(XLogReaderState *record) recoveryStopTime = 0; recoveryStopName[0] = '\0'; ereport(LOG, - (errmsg("recovery stopping before WAL location (LSN) \"%X/%X\"", - (uint32) (recoveryStopLSN >> 32), - (uint32) recoveryStopLSN))); + (errmsg("recovery stopping before WAL location (LSN) \"%X/%X\"", + (uint32) (recoveryStopLSN >> 32), + (uint32) recoveryStopLSN))); return true; } @@ -5800,9 +5800,9 @@ recoveryStopsAfter(XLogReaderState *record) recoveryStopTime = 0; recoveryStopName[0] = '\0'; ereport(LOG, - (errmsg("recovery stopping after WAL location (LSN) \"%X/%X\"", - (uint32) (recoveryStopLSN >> 32), - (uint32) recoveryStopLSN))); + (errmsg("recovery stopping after WAL location (LSN) \"%X/%X\"", + (uint32) (recoveryStopLSN >> 32), + (uint32) recoveryStopLSN))); return true; } @@ -6348,12 +6348,12 @@ StartupXLOG(void) ereport(ERROR, (errcode(ERRCODE_OUT_OF_MEMORY), errmsg("out of memory"), - errdetail("Failed while allocating a WAL reading processor."))); + errdetail("Failed while allocating a WAL reading processor."))); xlogreader->system_identifier = ControlFile->system_identifier; /* - * Allocate pages dedicated to WAL consistency checks, those had better - * be aligned. + * Allocate pages dedicated to WAL consistency checks, those had better be + * aligned. */ replay_image_masked = (char *) palloc(BLCKSZ); master_image_masked = (char *) palloc(BLCKSZ); @@ -6687,21 +6687,21 @@ StartupXLOG(void) /* * Copy any missing timeline history files between 'now' and the recovery - * target timeline from archive to pg_wal. While we don't need those - * files ourselves - the history file of the recovery target timeline - * covers all the previous timelines in the history too - a cascading - * standby server might be interested in them. Or, if you archive the WAL - * from this server to a different archive than the master, it'd be good - * for all the history files to get archived there after failover, so that - * you can use one of the old timelines as a PITR target. Timeline history - * files are small, so it's better to copy them unnecessarily than not - * copy them and regret later. + * target timeline from archive to pg_wal. While we don't need those files + * ourselves - the history file of the recovery target timeline covers all + * the previous timelines in the history too - a cascading standby server + * might be interested in them. Or, if you archive the WAL from this + * server to a different archive than the master, it'd be good for all the + * history files to get archived there after failover, so that you can use + * one of the old timelines as a PITR target. Timeline history files are + * small, so it's better to copy them unnecessarily than not copy them and + * regret later. */ restoreTimeLineHistoryFiles(ThisTimeLineID, recoveryTargetTLI); /* - * Before running in recovery, scan pg_twophase and fill in its status - * to be able to work on entries generated by redo. Doing a scan before + * Before running in recovery, scan pg_twophase and fill in its status to + * be able to work on entries generated by redo. Doing a scan before * taking any recovery action has the merit to discard any 2PC files that * are newer than the first record to replay, saving from any conflicts at * replay. This avoids as well any subsequent scans when doing recovery @@ -7426,7 +7426,7 @@ StartupXLOG(void) snprintf(reason, sizeof(reason), "%s LSN %X/%X\n", recoveryStopAfter ? "after" : "before", - (uint32 ) (recoveryStopLSN >> 32), + (uint32) (recoveryStopLSN >> 32), (uint32) recoveryStopLSN); else if (recoveryTarget == RECOVERY_TARGET_NAME) snprintf(reason, sizeof(reason), @@ -9645,6 +9645,7 @@ xlog_redo(XLogReaderState *record) MultiXactAdvanceOldest(checkPoint.oldestMulti, checkPoint.oldestMultiDB); + /* * No need to set oldestClogXid here as well; it'll be set when we * redo an xl_clog_truncate if it changed since initialization. @@ -10238,8 +10239,8 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p, if (exclusive) { /* - * At first, mark that we're now starting an exclusive backup, - * to ensure that there are no other sessions currently running + * At first, mark that we're now starting an exclusive backup, to + * ensure that there are no other sessions currently running * pg_start_backup() or pg_stop_backup(). */ if (XLogCtl->Insert.exclusiveBackupState != EXCLUSIVE_BACKUP_NONE) @@ -10505,8 +10506,9 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p, { /* * Check for existing backup label --- implies a backup is already - * running. (XXX given that we checked exclusiveBackupState above, - * maybe it would be OK to just unlink any such label file?) + * running. (XXX given that we checked exclusiveBackupState + * above, maybe it would be OK to just unlink any such label + * file?) */ if (stat(BACKUP_LABEL_FILE, &stat_buf) != 0) { @@ -10727,8 +10729,8 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) if (exclusive) { /* - * At first, mark that we're now stopping an exclusive backup, - * to ensure that there are no other sessions currently running + * At first, mark that we're now stopping an exclusive backup, to + * ensure that there are no other sessions currently running * pg_start_backup() or pg_stop_backup(). */ WALInsertLockAcquireExclusive(); @@ -10790,8 +10792,8 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) durable_unlink(BACKUP_LABEL_FILE, ERROR); /* - * Remove tablespace_map file if present, it is created only if there - * are tablespaces. + * Remove tablespace_map file if present, it is created only if + * there are tablespaces. */ durable_unlink(TABLESPACE_MAP, DEBUG1); } @@ -10978,9 +10980,9 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) * archived before returning. If archiving isn't enabled, the required WAL * needs to be transported via streaming replication (hopefully with * wal_keep_segments set high enough), or some more exotic mechanism like - * polling and copying files from pg_wal with script. We have no - * knowledge of those mechanisms, so it's up to the user to ensure that he - * gets all the required WAL. + * polling and copying files from pg_wal with script. We have no knowledge + * of those mechanisms, so it's up to the user to ensure that he gets all + * the required WAL. * * We wait until both the last WAL file filled during backup and the * history file have been archived, and assume that the alphabetic sorting @@ -10990,8 +10992,8 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) * We wait forever, since archive_command is supposed to work and we * assume the admin wanted his backup to work completely. If you don't * wish to wait, then either waitforarchive should be passed in as false, - * or you can set statement_timeout. Also, some notices are - * issued to clue in anyone who might be doing this interactively. + * or you can set statement_timeout. Also, some notices are issued to + * clue in anyone who might be doing this interactively. */ if (waitforarchive && XLogArchivingActive()) { @@ -11717,8 +11719,8 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, * little chance that the problem will just go away, but * PANIC is not good for availability either, especially * in hot standby mode. So, we treat that the same as - * disconnection, and retry from archive/pg_wal again. - * The WAL in the archive should be identical to what was + * disconnection, and retry from archive/pg_wal again. The + * WAL in the archive should be identical to what was * streamed, so it's unlikely that it helps, but one can * hope... */ @@ -11881,9 +11883,9 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, * not open already. Also read the timeline history * file if we haven't initialized timeline history * yet; it should be streamed over and present in - * pg_wal by now. Use XLOG_FROM_STREAM so that - * source info is set correctly and XLogReceiptTime - * isn't changed. + * pg_wal by now. Use XLOG_FROM_STREAM so that source + * info is set correctly and XLogReceiptTime isn't + * changed. */ if (readFile < 0) { diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c index 8568c8abd64..b3223d691da 100644 --- a/src/backend/access/transam/xlogfuncs.c +++ b/src/backend/access/transam/xlogfuncs.c @@ -156,7 +156,8 @@ pg_stop_backup(PG_FUNCTION_ARGS) * Exclusive backups were typically started in a different connection, so * don't try to verify that status of backup is set to * SESSION_BACKUP_EXCLUSIVE in this function. Actual verification that an - * exclusive backup is in fact running is handled inside do_pg_stop_backup. + * exclusive backup is in fact running is handled inside + * do_pg_stop_backup. */ stoppoint = do_pg_stop_backup(NULL, true, NULL); @@ -527,7 +528,7 @@ pg_walfile_name(PG_FUNCTION_ARGS) ereport(ERROR, (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), errmsg("recovery is in progress"), - errhint("pg_walfile_name() cannot be executed during recovery."))); + errhint("pg_walfile_name() cannot be executed during recovery."))); XLByteToPrevSeg(locationpoint, xlogsegno); XLogFileName(xlogfilename, ThisTimeLineID, xlogsegno); diff --git a/src/backend/access/transam/xloginsert.c b/src/backend/access/transam/xloginsert.c index a3bd0b7f51a..6a02738479c 100644 --- a/src/backend/access/transam/xloginsert.c +++ b/src/backend/access/transam/xloginsert.c @@ -388,10 +388,10 @@ XLogRegisterBufData(uint8 block_id, char *data, int len) * * The flags that can be used here are: * - XLOG_INCLUDE_ORIGIN, to determine if the replication origin should be - * included in the record. + * included in the record. * - XLOG_MARK_UNIMPORTANT, to signal that the record is not important for - * durability, which allows to avoid triggering WAL archiving and other - * background activity. + * durability, which allows to avoid triggering WAL archiving and other + * background activity. */ void XLogSetRecordFlags(uint8 flags) @@ -507,10 +507,10 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, hdr_rdt.data = hdr_scratch; /* - * Enforce consistency checks for this record if user is looking for - * it. Do this before at the beginning of this routine to give the - * possibility for callers of XLogInsert() to pass XLR_CHECK_CONSISTENCY - * directly for a record. + * Enforce consistency checks for this record if user is looking for it. + * Do this before at the beginning of this routine to give the possibility + * for callers of XLogInsert() to pass XLR_CHECK_CONSISTENCY directly for + * a record. */ if (wal_consistency_checking[rmid]) info |= XLR_CHECK_CONSISTENCY; @@ -576,9 +576,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, bkpb.fork_flags |= BKPBLOCK_WILL_INIT; /* - * If needs_backup is true or WAL checking is enabled for - * current resource manager, log a full-page write for the current - * block. + * If needs_backup is true or WAL checking is enabled for current + * resource manager, log a full-page write for the current block. */ include_image = needs_backup || (info & XLR_CHECK_CONSISTENCY) != 0; @@ -645,8 +644,8 @@ XLogRecordAssemble(RmgrId rmid, uint8 info, bimg.bimg_info = (cbimg.hole_length == 0) ? 0 : BKPIMAGE_HAS_HOLE; /* - * If WAL consistency checking is enabled for the resource manager of - * this WAL record, a full-page image is included in the record + * If WAL consistency checking is enabled for the resource manager + * of this WAL record, a full-page image is included in the record * for the block modified. During redo, the full-page is replayed * only if BKPIMAGE_APPLY is set. */ diff --git a/src/backend/access/transam/xlogreader.c b/src/backend/access/transam/xlogreader.c index f077662946f..c3b1371764b 100644 --- a/src/backend/access/transam/xlogreader.c +++ b/src/backend/access/transam/xlogreader.c @@ -892,8 +892,8 @@ XLogFindNextRecord(XLogReaderState *state, XLogRecPtr RecPtr) * that, except when caller has explicitly specified the offset that * falls somewhere there or when we are skipping multi-page * continuation record. It doesn't matter though because - * ReadPageInternal() is prepared to handle that and will read at least - * short page-header worth of data + * ReadPageInternal() is prepared to handle that and will read at + * least short page-header worth of data */ targetRecOff = tmpRecPtr % XLOG_BLCKSZ; diff --git a/src/backend/access/transam/xlogutils.c b/src/backend/access/transam/xlogutils.c index d7f2e55b090..7430a1f77b4 100644 --- a/src/backend/access/transam/xlogutils.c +++ b/src/backend/access/transam/xlogutils.c @@ -805,22 +805,23 @@ XLogReadDetermineTimeline(XLogReaderState *state, XLogRecPtr wantPage, uint32 wa Assert(state->readLen == 0 || state->readLen <= XLOG_BLCKSZ); /* - * If the desired page is currently read in and valid, we have nothing to do. + * If the desired page is currently read in and valid, we have nothing to + * do. * * The caller should've ensured that it didn't previously advance readOff - * past the valid limit of this timeline, so it doesn't matter if the current - * TLI has since become historical. + * past the valid limit of this timeline, so it doesn't matter if the + * current TLI has since become historical. */ if (lastReadPage == wantPage && state->readLen != 0 && - lastReadPage + state->readLen >= wantPage + Min(wantLength,XLOG_BLCKSZ-1)) + lastReadPage + state->readLen >= wantPage + Min(wantLength, XLOG_BLCKSZ - 1)) return; /* * If we're reading from the current timeline, it hasn't become historical * and the page we're reading is after the last page read, we can again - * just carry on. (Seeking backwards requires a check to make sure the older - * page isn't on a prior timeline). + * just carry on. (Seeking backwards requires a check to make sure the + * older page isn't on a prior timeline). * * ThisTimeLineID might've become historical since we last looked, but the * caller is required not to read past the flush limit it saw at the time @@ -835,8 +836,8 @@ XLogReadDetermineTimeline(XLogReaderState *state, XLogRecPtr wantPage, uint32 wa /* * If we're just reading pages from a previously validated historical - * timeline and the timeline we're reading from is valid until the - * end of the current segment we can just keep reading. + * timeline and the timeline we're reading from is valid until the end of + * the current segment we can just keep reading. */ if (state->currTLIValidUntil != InvalidXLogRecPtr && state->currTLI != ThisTimeLineID && @@ -845,10 +846,10 @@ XLogReadDetermineTimeline(XLogReaderState *state, XLogRecPtr wantPage, uint32 wa return; /* - * If we reach this point we're either looking up a page for random access, - * the current timeline just became historical, or we're reading from a new - * segment containing a timeline switch. In all cases we need to determine - * the newest timeline on the segment. + * If we reach this point we're either looking up a page for random + * access, the current timeline just became historical, or we're reading + * from a new segment containing a timeline switch. In all cases we need + * to determine the newest timeline on the segment. * * If it's the current timeline we can just keep reading from here unless * we detect a timeline switch that makes the current timeline historical. @@ -861,26 +862,29 @@ XLogReadDetermineTimeline(XLogReaderState *state, XLogRecPtr wantPage, uint32 wa * We need to re-read the timeline history in case it's been changed * by a promotion or replay from a cascaded replica. */ - List *timelineHistory = readTimeLineHistory(ThisTimeLineID); + List *timelineHistory = readTimeLineHistory(ThisTimeLineID); - XLogRecPtr endOfSegment = (((wantPage / XLogSegSize) + 1) * XLogSegSize) - 1; + XLogRecPtr endOfSegment = (((wantPage / XLogSegSize) + 1) * XLogSegSize) - 1; Assert(wantPage / XLogSegSize == endOfSegment / XLogSegSize); - /* Find the timeline of the last LSN on the segment containing wantPage. */ + /* + * Find the timeline of the last LSN on the segment containing + * wantPage. + */ state->currTLI = tliOfPointInHistory(endOfSegment, timelineHistory); state->currTLIValidUntil = tliSwitchPoint(state->currTLI, timelineHistory, - &state->nextTLI); + &state->nextTLI); Assert(state->currTLIValidUntil == InvalidXLogRecPtr || - wantPage + wantLength < state->currTLIValidUntil); + wantPage + wantLength < state->currTLIValidUntil); list_free_deep(timelineHistory); elog(DEBUG3, "switched to timeline %u valid until %X/%X", - state->currTLI, - (uint32)(state->currTLIValidUntil >> 32), - (uint32)(state->currTLIValidUntil)); + state->currTLI, + (uint32) (state->currTLIValidUntil >> 32), + (uint32) (state->currTLIValidUntil)); } } @@ -929,21 +933,22 @@ read_local_xlog_page(XLogReaderState *state, XLogRecPtr targetPagePtr, * * We have to do it each time through the loop because if we're in * recovery as a cascading standby, the current timeline might've - * become historical. We can't rely on RecoveryInProgress() because - * in a standby configuration like + * become historical. We can't rely on RecoveryInProgress() because in + * a standby configuration like * - * A => B => C + * A => B => C * * if we're a logical decoding session on C, and B gets promoted, our * timeline will change while we remain in recovery. * * We can't just keep reading from the old timeline as the last WAL - * archive in the timeline will get renamed to .partial by StartupXLOG(). + * archive in the timeline will get renamed to .partial by + * StartupXLOG(). * * If that happens after our caller updated ThisTimeLineID but before * we actually read the xlog page, we might still try to read from the - * old (now renamed) segment and fail. There's not much we can do about - * this, but it can only happen when we're a leaf of a cascading + * old (now renamed) segment and fail. There's not much we can do + * about this, but it can only happen when we're a leaf of a cascading * standby whose master gets promoted while we're decoding, so a * one-off ERROR isn't too bad. */ |