1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-16 15:02:33 +03:00

pgindent run for 9.0

This commit is contained in:
Bruce Momjian
2010-02-26 02:01:40 +00:00
parent 16040575a0
commit 65e806cba1
403 changed files with 6786 additions and 6530 deletions

View File

@@ -42,7 +42,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.34 2010/01/02 16:57:35 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.35 2010/02/26 02:00:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1298,11 +1298,11 @@ PostPrepare_MultiXact(TransactionId xid)
myOldestMember = OldestMemberMXactId[MyBackendId];
if (MultiXactIdIsValid(myOldestMember))
{
BackendId dummyBackendId = TwoPhaseGetDummyBackendId(xid);
BackendId dummyBackendId = TwoPhaseGetDummyBackendId(xid);
/*
* Even though storing MultiXactId is atomic, acquire lock to make sure
* others see both changes, not just the reset of the slot of the
* Even though storing MultiXactId is atomic, acquire lock to make
* sure others see both changes, not just the reset of the slot of the
* current backend. Using a volatile pointer might suffice, but this
* isn't a hot spot.
*/
@@ -1316,8 +1316,8 @@ PostPrepare_MultiXact(TransactionId xid)
/*
* We don't need to transfer OldestVisibleMXactId value, because the
* transaction is not going to be looking at any more multixacts once
* it's prepared.
* transaction is not going to be looking at any more multixacts once it's
* prepared.
*
* We assume that storing a MultiXactId is atomic and so we need not take
* MultiXactGenLock to do this.
@@ -1340,14 +1340,14 @@ multixact_twophase_recover(TransactionId xid, uint16 info,
void *recdata, uint32 len)
{
BackendId dummyBackendId = TwoPhaseGetDummyBackendId(xid);
MultiXactId oldestMember;
MultiXactId oldestMember;
/*
* Get the oldest member XID from the state file record, and set it in
* the OldestMemberMXactId slot reserved for this prepared transaction.
* Get the oldest member XID from the state file record, and set it in the
* OldestMemberMXactId slot reserved for this prepared transaction.
*/
Assert(len == sizeof(MultiXactId));
oldestMember = *((MultiXactId *)recdata);
oldestMember = *((MultiXactId *) recdata);
OldestMemberMXactId[dummyBackendId] = oldestMember;
}
@@ -1373,7 +1373,7 @@ multixact_twophase_postcommit(TransactionId xid, uint16 info,
*/
void
multixact_twophase_postabort(TransactionId xid, uint16 info,
void *recdata, uint32 len)
void *recdata, uint32 len)
{
multixact_twophase_postcommit(xid, info, recdata, len);
}
@@ -2031,9 +2031,10 @@ multixact_redo(XLogRecPtr lsn, XLogRecord *record)
max_xid = xids[i];
}
/* We don't expect anyone else to modify nextXid, hence startup process
* doesn't need to hold a lock while checking this. We still acquire
* the lock to modify it, though.
/*
* We don't expect anyone else to modify nextXid, hence startup
* process doesn't need to hold a lock while checking this. We still
* acquire the lock to modify it, though.
*/
if (TransactionIdFollowsOrEquals(max_xid,
ShmemVariableCache->nextXid))

View File

@@ -22,7 +22,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.26 2010/01/02 16:57:35 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.27 2010/02/26 02:00:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -89,7 +89,7 @@ SubTransSetParent(TransactionId xid, TransactionId parent, bool overwriteOK)
/* Current state should be 0 */
Assert(*ptr == InvalidTransactionId ||
(*ptr == parent && overwriteOK));
(*ptr == parent && overwriteOK));
*ptr = parent;

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.58 2010/01/02 16:57:35 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.59 2010/02/26 02:00:34 momjian Exp $
*
* NOTES
* Each global transaction is associated with a global transaction
@@ -110,7 +110,7 @@ int max_prepared_xacts = 0;
typedef struct GlobalTransactionData
{
PGPROC proc; /* dummy proc */
BackendId dummyBackendId; /* similar to backend id for backends */
BackendId dummyBackendId; /* similar to backend id for backends */
TimestampTz prepared_at; /* time of preparation */
XLogRecPtr prepare_lsn; /* XLOG offset of prepare record */
Oid owner; /* ID of user that executed the xact */
@@ -209,14 +209,14 @@ TwoPhaseShmemInit(void)
/*
* Assign a unique ID for each dummy proc, so that the range of
* dummy backend IDs immediately follows the range of normal
* backend IDs. We don't dare to assign a real backend ID to
* dummy procs, because prepared transactions don't take part in
* cache invalidation like a real backend ID would imply, but
* having a unique ID for them is nevertheless handy. This
* arrangement allows you to allocate an array of size
* (MaxBackends + max_prepared_xacts + 1), and have a slot for
* every backend and prepared transaction. Currently multixact.c
* uses that technique.
* backend IDs. We don't dare to assign a real backend ID to dummy
* procs, because prepared transactions don't take part in cache
* invalidation like a real backend ID would imply, but having a
* unique ID for them is nevertheless handy. This arrangement
* allows you to allocate an array of size (MaxBackends +
* max_prepared_xacts + 1), and have a slot for every backend and
* prepared transaction. Currently multixact.c uses that
* technique.
*/
gxacts[i].dummyBackendId = MaxBackends + 1 + i;
}
@@ -677,7 +677,7 @@ pg_prepared_xact(PG_FUNCTION_ARGS)
BackendId
TwoPhaseGetDummyBackendId(TransactionId xid)
{
PGPROC *proc = TwoPhaseGetDummyProc(xid);
PGPROC *proc = TwoPhaseGetDummyProc(xid);
return ((GlobalTransaction) proc)->dummyBackendId;
}
@@ -874,8 +874,8 @@ StartPrepare(GlobalTransaction gxact)
save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
/*
* Add the additional info about subxacts, deletable files and
* cache invalidation messages.
* Add the additional info about subxacts, deletable files and cache
* invalidation messages.
*/
if (hdr.nsubxacts > 0)
{
@@ -1331,8 +1331,8 @@ FinishPreparedTransaction(const char *gid, bool isCommit)
/*
* Handle cache invalidation messages.
*
* Relcache init file invalidation requires processing both
* before and after we send the SI messages. See AtEOXact_Inval()
* Relcache init file invalidation requires processing both before and
* after we send the SI messages. See AtEOXact_Inval()
*/
if (hdr->initfileinval)
RelationCacheInitFileInvalidate(true);
@@ -1786,8 +1786,8 @@ RecoverPreparedTransactions(void)
bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
/*
* It's possible that SubTransSetParent has been set before, if the
* prepared transaction generated xid assignment records. Test
* It's possible that SubTransSetParent has been set before, if
* the prepared transaction generated xid assignment records. Test
* here must match one used in AssignTransactionId().
*/
if (InHotStandby && hdr->nsubxacts >= PGPROC_MAX_CACHED_SUBXIDS)

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.13 2010/02/16 22:34:43 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.14 2010/02/26 02:00:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -32,8 +32,8 @@ const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] =
{
NULL, /* END ID */
lock_twophase_postcommit, /* Lock */
pgstat_twophase_postcommit, /* pgstat */
multixact_twophase_postcommit /* MultiXact */
pgstat_twophase_postcommit, /* pgstat */
multixact_twophase_postcommit /* MultiXact */
};
const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] =
@@ -41,7 +41,7 @@ const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID + 1] =
NULL, /* END ID */
lock_twophase_postabort, /* Lock */
pgstat_twophase_postabort, /* pgstat */
multixact_twophase_postabort /* MultiXact */
multixact_twophase_postabort /* MultiXact */
};
const TwoPhaseCallback twophase_standby_recover_callbacks[TWOPHASE_RM_MAX_ID + 1] =

View File

@@ -6,7 +6,7 @@
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.90 2010/02/20 21:24:01 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.91 2010/02/26 02:00:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -39,7 +39,7 @@ VariableCache ShmemVariableCache = NULL;
*
* Note: when this is called, we are actually already inside a valid
* transaction, since XIDs are now not allocated until the transaction
* does something. So it is safe to do a database lookup if we want to
* does something. So it is safe to do a database lookup if we want to
* issue a warning about XID wrap.
*/
TransactionId
@@ -83,13 +83,13 @@ GetNewTransactionId(bool isSubXact)
* For safety's sake, we release XidGenLock while sending signals,
* warnings, etc. This is not so much because we care about
* preserving concurrency in this situation, as to avoid any
* possibility of deadlock while doing get_database_name().
* First, copy all the shared values we'll need in this path.
* possibility of deadlock while doing get_database_name(). First,
* copy all the shared values we'll need in this path.
*/
TransactionId xidWarnLimit = ShmemVariableCache->xidWarnLimit;
TransactionId xidStopLimit = ShmemVariableCache->xidStopLimit;
TransactionId xidWrapLimit = ShmemVariableCache->xidWrapLimit;
Oid oldest_datoid = ShmemVariableCache->oldestXidDB;
Oid oldest_datoid = ShmemVariableCache->oldestXidDB;
LWLockRelease(XidGenLock);
@@ -104,7 +104,7 @@ GetNewTransactionId(bool isSubXact)
if (IsUnderPostmaster &&
TransactionIdFollowsOrEquals(xid, xidStopLimit))
{
char *oldest_datname = get_database_name(oldest_datoid);
char *oldest_datname = get_database_name(oldest_datoid);
/* complain even if that DB has disappeared */
if (oldest_datname)
@@ -124,7 +124,7 @@ GetNewTransactionId(bool isSubXact)
}
else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit))
{
char *oldest_datname = get_database_name(oldest_datoid);
char *oldest_datname = get_database_name(oldest_datoid);
/* complain even if that DB has disappeared */
if (oldest_datname)
@@ -329,8 +329,8 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
/* Log the info */
ereport(DEBUG1,
(errmsg("transaction ID wrap limit is %u, limited by database with OID %u",
xidWrapLimit, oldest_datoid)));
(errmsg("transaction ID wrap limit is %u, limited by database with OID %u",
xidWrapLimit, oldest_datoid)));
/*
* If past the autovacuum force point, immediately signal an autovac
@@ -346,7 +346,7 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
/* Give an immediate warning if past the wrap warn point */
if (TransactionIdFollowsOrEquals(curXid, xidWarnLimit) && !InRecovery)
{
char *oldest_datname = get_database_name(oldest_datoid);
char *oldest_datname = get_database_name(oldest_datoid);
/*
* Note: it's possible that get_database_name fails and returns NULL,
@@ -355,11 +355,11 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
*/
if (oldest_datname)
ereport(WARNING,
(errmsg("database \"%s\" must be vacuumed within %u transactions",
oldest_datname,
xidWrapLimit - curXid),
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
"You might also need to commit or roll back old prepared transactions.")));
(errmsg("database \"%s\" must be vacuumed within %u transactions",
oldest_datname,
xidWrapLimit - curXid),
errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
"You might also need to commit or roll back old prepared transactions.")));
else
ereport(WARNING,
(errmsg("database with OID %u must be vacuumed within %u transactions",
@@ -377,7 +377,7 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
* We primarily check whether oldestXidDB is valid. The cases we have in
* mind are that that database was dropped, or the field was reset to zero
* by pg_resetxlog. In either case we should force recalculation of the
* wrap limit. Also do it if oldestXid is old enough to be forcing
* wrap limit. Also do it if oldestXid is old enough to be forcing
* autovacuums or other actions; this ensures we update our state as soon
* as possible once extra overhead is being incurred.
*/

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.288 2010/02/20 21:24:01 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.289 2010/02/26 02:00:34 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -139,9 +139,9 @@ typedef struct TransactionStateData
int nChildXids; /* # of subcommitted child XIDs */
int maxChildXids; /* allocated size of childXids[] */
Oid prevUser; /* previous CurrentUserId setting */
int prevSecContext; /* previous SecurityRestrictionContext */
int prevSecContext; /* previous SecurityRestrictionContext */
bool prevXactReadOnly; /* entry-time xact r/o state */
bool startedInRecovery; /* did we start in recovery? */
bool startedInRecovery; /* did we start in recovery? */
struct TransactionStateData *parent; /* back link to parent */
} TransactionStateData;
@@ -178,7 +178,7 @@ static TransactionStateData TopTransactionStateData = {
* unreportedXids holds XIDs of all subtransactions that have not yet been
* reported in a XLOG_XACT_ASSIGNMENT record.
*/
static int nUnreportedXids;
static int nUnreportedXids;
static TransactionId unreportedXids[PGPROC_MAX_CACHED_SUBXIDS];
static TransactionState CurrentTransactionState = &TopTransactionStateData;
@@ -452,25 +452,28 @@ AssignTransactionId(TransactionState s)
* include the top-level xid and all the subxids that have not yet been
* reported using XLOG_XACT_ASSIGNMENT records.
*
* This is required to limit the amount of shared memory required in a
* hot standby server to keep track of in-progress XIDs. See notes for
* This is required to limit the amount of shared memory required in a hot
* standby server to keep track of in-progress XIDs. See notes for
* RecordKnownAssignedTransactionIds().
*
* We don't keep track of the immediate parent of each subxid,
* only the top-level transaction that each subxact belongs to. This
* is correct in recovery only because aborted subtransactions are
* separately WAL logged.
* We don't keep track of the immediate parent of each subxid, only the
* top-level transaction that each subxact belongs to. This is correct in
* recovery only because aborted subtransactions are separately WAL
* logged.
*/
if (isSubXact && XLogStandbyInfoActive())
{
unreportedXids[nUnreportedXids] = s->transactionId;
nUnreportedXids++;
/* ensure this test matches similar one in RecoverPreparedTransactions() */
/*
* ensure this test matches similar one in
* RecoverPreparedTransactions()
*/
if (nUnreportedXids >= PGPROC_MAX_CACHED_SUBXIDS)
{
XLogRecData rdata[2];
xl_xact_assignment xlrec;
xl_xact_assignment xlrec;
/*
* xtop is always set by now because we recurse up transaction
@@ -899,6 +902,7 @@ RecordTransactionCommit(void)
nchildren = xactGetCommittedChildren(&children);
nmsgs = xactGetCommittedInvalidationMessages(&invalMessages,
&RelcacheInitFileInval);
/*
* If we haven't been assigned an XID yet, we neither can, nor do we want
* to write a COMMIT record.
@@ -1098,10 +1102,9 @@ static void
AtCCI_LocalCache(void)
{
/*
* Make any pending relation map changes visible. We must do this
* before processing local sinval messages, so that the map changes
* will get reflected into the relcache when relcache invals are
* processed.
* Make any pending relation map changes visible. We must do this before
* processing local sinval messages, so that the map changes will get
* reflected into the relcache when relcache invals are processed.
*/
AtCCI_RelationMap();
@@ -1227,9 +1230,9 @@ AtSubCommit_childXids(void)
*
* Note: We rely on the fact that the XID of a child always follows that
* of its parent. By copying the XID of this subtransaction before the
* XIDs of its children, we ensure that the array stays ordered.
* Likewise, all XIDs already in the array belong to subtransactions
* started and subcommitted before us, so their XIDs must precede ours.
* XIDs of its children, we ensure that the array stays ordered. Likewise,
* all XIDs already in the array belong to subtransactions started and
* subcommitted before us, so their XIDs must precede ours.
*/
s->parent->childXids[s->parent->nChildXids] = s->transactionId;
@@ -1457,10 +1460,10 @@ AtSubAbort_childXids(void)
s->maxChildXids = 0;
/*
* We could prune the unreportedXids array here. But we don't bother.
* That would potentially reduce number of XLOG_XACT_ASSIGNMENT records
* but it would likely introduce more CPU time into the more common
* paths, so we choose not to do that.
* We could prune the unreportedXids array here. But we don't bother. That
* would potentially reduce number of XLOG_XACT_ASSIGNMENT records but it
* would likely introduce more CPU time into the more common paths, so we
* choose not to do that.
*/
}
@@ -2162,7 +2165,7 @@ AbortTransaction(void)
/*
* do abort processing
*/
AfterTriggerEndXact(false); /* 'false' means it's abort */
AfterTriggerEndXact(false); /* 'false' means it's abort */
AtAbort_Portals();
AtEOXact_LargeObject(false);
AtAbort_Notify();
@@ -4362,9 +4365,9 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn)
/*
* Make sure nextXid is beyond any XID mentioned in the record.
*
* We don't expect anyone else to modify nextXid, hence we
* don't need to hold a lock while checking this. We still acquire
* the lock to modify it, though.
* We don't expect anyone else to modify nextXid, hence we don't need to
* hold a lock while checking this. We still acquire the lock to modify
* it, though.
*/
if (TransactionIdFollowsOrEquals(max_xid,
ShmemVariableCache->nextXid))
@@ -4400,8 +4403,8 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn)
* protocol during recovery to provide information on database
* consistency for when users try to set hint bits. It is important
* that we do not set hint bits until the minRecoveryPoint is past
* this commit record. This ensures that if we crash we don't see
* hint bits set on changes made by transactions that haven't yet
* this commit record. This ensures that if we crash we don't see hint
* bits set on changes made by transactions that haven't yet
* recovered. It's unlikely but it's good to be safe.
*/
TransactionIdAsyncCommitTree(xid, xlrec->nsubxacts, sub_xids, lsn);
@@ -4413,17 +4416,17 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn)
/*
* Send any cache invalidations attached to the commit. We must
* maintain the same order of invalidation then release locks
* as occurs in .
* maintain the same order of invalidation then release locks as
* occurs in .
*/
ProcessCommittedInvalidationMessages(inval_msgs, xlrec->nmsgs,
XactCompletionRelcacheInitFileInval(xlrec),
xlrec->dbId, xlrec->tsId);
XactCompletionRelcacheInitFileInval(xlrec),
xlrec->dbId, xlrec->tsId);
/*
* Release locks, if any. We do this for both two phase and normal
* one phase transactions. In effect we are ignoring the prepare
* phase and just going straight to lock release.
* Release locks, if any. We do this for both two phase and normal one
* phase transactions. In effect we are ignoring the prepare phase and
* just going straight to lock release.
*/
StandbyReleaseLockTree(xid, xlrec->nsubxacts, sub_xids);
}
@@ -4446,15 +4449,16 @@ xact_redo_commit(xl_xact_commit *xlrec, TransactionId xid, XLogRecPtr lsn)
}
/*
* We issue an XLogFlush() for the same reason we emit ForceSyncCommit() in
* normal operation. For example, in DROP DATABASE, we delete all the files
* belonging to the database, and then commit the transaction. If we crash
* after all the files have been deleted but before the commit, you have an
* entry in pg_database without any files. To minimize the window for that,
* we use ForceSyncCommit() to rush the commit record to disk as quick as
* possible. We have the same window during recovery, and forcing an
* XLogFlush() (which updates minRecoveryPoint during recovery) helps
* to reduce that problem window, for any user that requested ForceSyncCommit().
* We issue an XLogFlush() for the same reason we emit ForceSyncCommit()
* in normal operation. For example, in DROP DATABASE, we delete all the
* files belonging to the database, and then commit the transaction. If we
* crash after all the files have been deleted but before the commit, you
* have an entry in pg_database without any files. To minimize the window
* for that, we use ForceSyncCommit() to rush the commit record to disk as
* quick as possible. We have the same window during recovery, and forcing
* an XLogFlush() (which updates minRecoveryPoint during recovery) helps
* to reduce that problem window, for any user that requested
* ForceSyncCommit().
*/
if (XactCompletionForceSyncCommit(xlrec))
XLogFlush(lsn);
@@ -4480,9 +4484,11 @@ xact_redo_abort(xl_xact_abort *xlrec, TransactionId xid)
max_xid = TransactionIdLatest(xid, xlrec->nsubxacts, sub_xids);
/* Make sure nextXid is beyond any XID mentioned in the record */
/* We don't expect anyone else to modify nextXid, hence we
* don't need to hold a lock while checking this. We still acquire
* the lock to modify it, though.
/*
* We don't expect anyone else to modify nextXid, hence we don't need to
* hold a lock while checking this. We still acquire the lock to modify
* it, though.
*/
if (TransactionIdFollowsOrEquals(max_xid,
ShmemVariableCache->nextXid))
@@ -4496,12 +4502,13 @@ xact_redo_abort(xl_xact_abort *xlrec, TransactionId xid)
if (InHotStandby)
{
/*
* If a transaction completion record arrives that has as-yet unobserved
* subtransactions then this will not have been fully handled by the call
* to RecordKnownAssignedTransactionIds() in the main recovery loop in
* xlog.c. So we need to do bookkeeping again to cover that case. This is
* confusing and it is easy to think this call is irrelevant, which has
* happened three times in development already. Leave it in.
* If a transaction completion record arrives that has as-yet
* unobserved subtransactions then this will not have been fully
* handled by the call to RecordKnownAssignedTransactionIds() in the
* main recovery loop in xlog.c. So we need to do bookkeeping again to
* cover that case. This is confusing and it is easy to think this
* call is irrelevant, which has happened three times in development
* already. Leave it in.
*/
RecordKnownAssignedTransactionIds(max_xid);
}
@@ -4631,8 +4638,8 @@ xact_desc_commit(StringInfo buf, xl_xact_commit *xlrec)
msgs = (SharedInvalidationMessage *) &xacts[xlrec->nsubxacts];
if (XactCompletionRelcacheInitFileInval(xlrec))
appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
xlrec->dbId, xlrec->tsId);
appendStringInfo(buf, "; relcache init file inval dbid %u tsid %u",
xlrec->dbId, xlrec->tsId);
appendStringInfo(buf, "; inval msgs:");
for (i = 0; i < xlrec->nmsgs; i++)
@@ -4738,8 +4745,8 @@ xact_desc(StringInfo buf, uint8 xl_info, char *rec)
/*
* Note that we ignore the WAL record's xid, since we're more
* interested in the top-level xid that issued the record
* and which xids are being reported here.
* interested in the top-level xid that issued the record and which
* xids are being reported here.
*/
appendStringInfo(buf, "xid assignment xtop %u: ", xlrec->xtop);
xact_desc_assignment(buf, xlrec);

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.378 2010/02/25 02:17:50 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.379 2010/02/26 02:00:35 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,7 +70,7 @@ int XLOGbuffers = 8;
int XLogArchiveTimeout = 0;
bool XLogArchiveMode = false;
char *XLogArchiveCommand = NULL;
bool XLogRequestRecoveryConnections = true;
bool XLogRequestRecoveryConnections = true;
int MaxStandbyDelay = 30;
bool fullPageWrites = true;
bool log_checkpoints = false;
@@ -140,9 +140,9 @@ TimeLineID ThisTimeLineID = 0;
bool InRecovery = false;
/* Are we in Hot Standby mode? Only valid in startup process, see xlog.h */
HotStandbyState standbyState = STANDBY_DISABLED;
HotStandbyState standbyState = STANDBY_DISABLED;
static XLogRecPtr LastRec;
static XLogRecPtr LastRec;
/*
* Local copy of SharedRecoveryInProgress variable. True actually means "not
@@ -156,7 +156,7 @@ static bool LocalRecoveryInProgress = true;
* 0: unconditionally not allowed to insert XLOG
* -1: must check RecoveryInProgress(); disallow until it is false
* Most processes start with -1 and transition to 1 after seeing that recovery
* is not in progress. But we can also force the value for special cases.
* is not in progress. But we can also force the value for special cases.
* The coding in XLogInsertAllowed() depends on the first two of these states
* being numerically the same as bool true and false.
*/
@@ -181,7 +181,7 @@ static TimestampTz recoveryLastXTime = 0;
/* options taken from recovery.conf for XLOG streaming */
static bool StandbyMode = false;
static char *PrimaryConnInfo = NULL;
char *TriggerFile = NULL;
char *TriggerFile = NULL;
/* if recoveryStopsHere returns true, it saves actual stop xid/time here */
static TransactionId recoveryStopXid;
@@ -389,7 +389,7 @@ typedef struct XLogCtlData
/* end+1 of the last record replayed (or being replayed) */
XLogRecPtr replayEndRecPtr;
/* timestamp of last record replayed (or being replayed) */
TimestampTz recoveryLastXTime;
TimestampTz recoveryLastXTime;
/* end+1 of the last record replayed */
XLogRecPtr recoveryLastRecPtr;
@@ -456,6 +456,7 @@ static uint32 readId = 0;
static uint32 readSeg = 0;
static uint32 readOff = 0;
static uint32 readLen = 0;
/* Is the currently open segment being streamed from primary? */
static bool readStreamed = false;
@@ -510,9 +511,9 @@ static void XLogWrite(XLogwrtRqst WriteRqst, bool flexible, bool xlog_switch);
static bool InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath,
bool find_free, int *max_advance,
bool use_lock);
static int XLogFileRead(uint32 log, uint32 seg, int emode, TimeLineID tli,
static int XLogFileRead(uint32 log, uint32 seg, int emode, TimeLineID tli,
bool fromArchive, bool notexistOk);
static int XLogFileReadAnyTLI(uint32 log, uint32 seg, int emode,
static int XLogFileReadAnyTLI(uint32 log, uint32 seg, int emode,
bool fromArchive);
static bool XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
bool randAccess);
@@ -1867,10 +1868,10 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force)
* to not need a valid 'lsn' value.
*
* Another important reason for doing it this way is that the passed
* 'lsn' value could be bogus, i.e., past the end of available WAL,
* if the caller got it from a corrupted heap page. Accepting such
* a value as the min recovery point would prevent us from coming up
* at all. Instead, we just log a warning and continue with recovery.
* 'lsn' value could be bogus, i.e., past the end of available WAL, if
* the caller got it from a corrupted heap page. Accepting such a
* value as the min recovery point would prevent us from coming up at
* all. Instead, we just log a warning and continue with recovery.
* (See also the comments about corrupt LSNs in XLogFlush.)
*/
SpinLockAcquire(&xlogctl->info_lck);
@@ -1879,7 +1880,7 @@ UpdateMinRecoveryPoint(XLogRecPtr lsn, bool force)
if (!force && XLByteLT(newMinRecoveryPoint, lsn))
elog(WARNING,
"xlog min recovery request %X/%X is past current point %X/%X",
"xlog min recovery request %X/%X is past current point %X/%X",
lsn.xlogid, lsn.xrecoff,
newMinRecoveryPoint.xlogid, newMinRecoveryPoint.xrecoff);
@@ -1912,10 +1913,10 @@ XLogFlush(XLogRecPtr record)
/*
* During REDO, we are reading not writing WAL. Therefore, instead of
* trying to flush the WAL, we should update minRecoveryPoint instead.
* We test XLogInsertAllowed(), not InRecovery, because we need the
* bgwriter to act this way too, and because when the bgwriter tries
* to write the end-of-recovery checkpoint, it should indeed flush.
* trying to flush the WAL, we should update minRecoveryPoint instead. We
* test XLogInsertAllowed(), not InRecovery, because we need the bgwriter
* to act this way too, and because when the bgwriter tries to write the
* end-of-recovery checkpoint, it should indeed flush.
*/
if (!XLogInsertAllowed())
{
@@ -2007,16 +2008,16 @@ XLogFlush(XLogRecPtr record)
* the whole system due to corruption on one data page. In particular, if
* the bad page is encountered again during recovery then we would be
* unable to restart the database at all! (This scenario actually
* happened in the field several times with 7.1 releases.) As of 8.4,
* bad LSNs encountered during recovery are UpdateMinRecoveryPoint's
* problem; the only time we can reach here during recovery is while
* flushing the end-of-recovery checkpoint record, and we don't expect
* that to have a bad LSN.
* happened in the field several times with 7.1 releases.) As of 8.4, bad
* LSNs encountered during recovery are UpdateMinRecoveryPoint's problem;
* the only time we can reach here during recovery is while flushing the
* end-of-recovery checkpoint record, and we don't expect that to have a
* bad LSN.
*
* Note that for calls from xact.c, the ERROR will
* be promoted to PANIC since xact.c calls this routine inside a critical
* section. However, calls from bufmgr.c are not within critical sections
* and so we will not force a restart for a bad LSN on a data page.
* Note that for calls from xact.c, the ERROR will be promoted to PANIC
* since xact.c calls this routine inside a critical section. However,
* calls from bufmgr.c are not within critical sections and so we will not
* force a restart for a bad LSN on a data page.
*/
if (XLByteLT(LogwrtResult.Flush, record))
elog(ERROR,
@@ -2136,9 +2137,10 @@ XLogNeedsFlush(XLogRecPtr record)
LWLockRelease(ControlFileLock);
/*
* An invalid minRecoveryPoint means that we need to recover all the WAL,
* i.e., we're doing crash recovery. We never modify the control file's
* value in that case, so we can short-circuit future checks here too.
* An invalid minRecoveryPoint means that we need to recover all the
* WAL, i.e., we're doing crash recovery. We never modify the control
* file's value in that case, so we can short-circuit future checks
* here too.
*/
if (minRecoveryPoint.xlogid == 0 && minRecoveryPoint.xrecoff == 0)
updateMinRecoveryPoint = false;
@@ -2572,46 +2574,46 @@ XLogFileRead(uint32 log, uint32 seg, int emode, TimeLineID tli,
char path[MAXPGPATH];
int fd;
XLogFileName(xlogfname, tli, log, seg);
XLogFileName(xlogfname, tli, log, seg);
if (fromArchive)
{
/* Report recovery progress in PS display */
snprintf(activitymsg, sizeof(activitymsg), "waiting for %s",
xlogfname);
set_ps_display(activitymsg, false);
if (fromArchive)
{
/* Report recovery progress in PS display */
snprintf(activitymsg, sizeof(activitymsg), "waiting for %s",
xlogfname);
set_ps_display(activitymsg, false);
restoredFromArchive = RestoreArchivedFile(path, xlogfname,
"RECOVERYXLOG",
XLogSegSize);
if (!restoredFromArchive)
return -1;
}
else
{
XLogFilePath(path, tli, log, seg);
restoredFromArchive = false;
}
restoredFromArchive = RestoreArchivedFile(path, xlogfname,
"RECOVERYXLOG",
XLogSegSize);
if (!restoredFromArchive)
return -1;
}
else
{
XLogFilePath(path, tli, log, seg);
restoredFromArchive = false;
}
fd = BasicOpenFile(path, O_RDONLY | PG_BINARY, 0);
if (fd >= 0)
{
/* Success! */
curFileTLI = tli;
fd = BasicOpenFile(path, O_RDONLY | PG_BINARY, 0);
if (fd >= 0)
{
/* Success! */
curFileTLI = tli;
/* Report recovery progress in PS display */
snprintf(activitymsg, sizeof(activitymsg), "recovering %s",
xlogfname);
set_ps_display(activitymsg, false);
/* Report recovery progress in PS display */
snprintf(activitymsg, sizeof(activitymsg), "recovering %s",
xlogfname);
set_ps_display(activitymsg, false);
return fd;
}
if (errno != ENOENT || !notfoundOk) /* unexpected failure? */
ereport(PANIC,
(errcode_for_file_access(),
errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
path, log, seg)));
return -1;
return fd;
}
if (errno != ENOENT || !notfoundOk) /* unexpected failure? */
ereport(PANIC,
(errcode_for_file_access(),
errmsg("could not open file \"%s\" (log file %u, segment %u): %m",
path, log, seg)));
return -1;
}
/*
@@ -2653,8 +2655,8 @@ XLogFileReadAnyTLI(uint32 log, uint32 seg, int emode, bool fromArchive)
* If not in StandbyMode, fall back to searching pg_xlog. In
* StandbyMode we're streaming segments from the primary to pg_xlog,
* and we mustn't confuse the (possibly partial) segments in pg_xlog
* with complete segments ready to be applied. We rather wait for
* the records to arrive through streaming.
* with complete segments ready to be applied. We rather wait for the
* records to arrive through streaming.
*/
if (!StandbyMode && fromArchive)
{
@@ -2685,8 +2687,8 @@ XLogFileClose(void)
/*
* WAL segment files will not be re-read in normal operation, so we advise
* the OS to release any cached pages. But do not do so if WAL archiving
* or streaming is active, because archiver and walsender process could use
* the cache to read the WAL segment.
* or streaming is active, because archiver and walsender process could
* use the cache to read the WAL segment.
*/
#if defined(USE_POSIX_FADVISE) && defined(POSIX_FADV_DONTNEED)
if (!XLogIsNeeded())
@@ -2893,7 +2895,7 @@ RestoreArchivedFile(char *path, const char *xlogfname,
{
if (expectedSize > 0 && stat_buf.st_size != expectedSize)
{
int elevel;
int elevel;
/*
* If we find a partial file in standby mode, we assume it's
@@ -2901,11 +2903,11 @@ RestoreArchivedFile(char *path, const char *xlogfname,
* trying.
*
* Otherwise treat a wrong-sized file as FATAL to ensure the
* DBA would notice it, but is that too strong? We could try
* DBA would notice it, but is that too strong? We could try
* to plow ahead with a local copy of the file ... but the
* problem is that there probably isn't one, and we'd
* incorrectly conclude we've reached the end of WAL and
* we're done recovering ...
* incorrectly conclude we've reached the end of WAL and we're
* done recovering ...
*/
if (StandbyMode && stat_buf.st_size < expectedSize)
elevel = DEBUG1;
@@ -2975,6 +2977,7 @@ RestoreArchivedFile(char *path, const char *xlogfname,
xlogfname, rc)));
not_available:
/*
* if an archived file is not available, there might still be a version of
* this file in XLOGDIR, so return that as the filename to open.
@@ -3141,6 +3144,7 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr)
struct dirent *xlde;
char lastoff[MAXFNAMELEN];
char path[MAXPGPATH];
#ifdef WIN32
char newpath[MAXPGPATH];
#endif
@@ -3218,21 +3222,22 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr)
else
{
/* No need for any more future segments... */
int rc;
int rc;
ereport(DEBUG2,
(errmsg("removing transaction log file \"%s\"",
xlde->d_name)));
#ifdef WIN32
/*
* On Windows, if another process (e.g another backend)
* holds the file open in FILE_SHARE_DELETE mode, unlink
* will succeed, but the file will still show up in
* directory listing until the last handle is closed.
* To avoid confusing the lingering deleted file for a
* live WAL file that needs to be archived, rename it
* before deleting it.
* directory listing until the last handle is closed. To
* avoid confusing the lingering deleted file for a live
* WAL file that needs to be archived, rename it before
* deleting it.
*
* If another process holds the file open without
* FILE_SHARE_DELETE flag, rename will fail. We'll try
@@ -3553,8 +3558,8 @@ ReadRecord(XLogRecPtr *RecPtr, int emode_arg, bool fetching_ckpt)
RecPtr = &tmpRecPtr;
/*
* Align recptr to next page if no more records can fit on the
* current page.
* Align recptr to next page if no more records can fit on the current
* page.
*/
if (XLOG_BLCKSZ - (RecPtr->xrecoff % XLOG_BLCKSZ) < SizeOfXLogRecord)
{
@@ -5093,8 +5098,8 @@ exitArchiveRecovery(TimeLineID endTLI, uint32 endLogId, uint32 endLogSeg)
UpdateMinRecoveryPoint(InvalidXLogRecPtr, true);
/*
* If the ending log segment is still open, close it (to avoid
* problems on Windows with trying to rename or delete an open file).
* If the ending log segment is still open, close it (to avoid problems on
* Windows with trying to rename or delete an open file).
*/
if (readFile >= 0)
{
@@ -5376,17 +5381,17 @@ CheckRequiredParameterValues(CheckPoint checkPoint)
{
/* We ignore autovacuum_max_workers when we make this test. */
RecoveryRequiresIntParameter("max_connections",
MaxConnections, checkPoint.MaxConnections);
MaxConnections, checkPoint.MaxConnections);
RecoveryRequiresIntParameter("max_prepared_xacts",
max_prepared_xacts, checkPoint.max_prepared_xacts);
max_prepared_xacts, checkPoint.max_prepared_xacts);
RecoveryRequiresIntParameter("max_locks_per_xact",
max_locks_per_xact, checkPoint.max_locks_per_xact);
max_locks_per_xact, checkPoint.max_locks_per_xact);
if (!checkPoint.XLogStandbyInfoMode)
ereport(ERROR,
(errmsg("recovery connections cannot start because the recovery_connections "
"parameter is disabled on the WAL source server")));
(errmsg("recovery connections cannot start because the recovery_connections "
"parameter is disabled on the WAL source server")));
}
/*
@@ -5464,12 +5469,12 @@ StartupXLOG(void)
ValidateXLOGDirectoryStructure();
/*
* Clear out any old relcache cache files. This is *necessary* if we
* do any WAL replay, since that would probably result in the cache files
* being out of sync with database reality. In theory we could leave
* them in place if the database had been cleanly shut down, but it
* seems safest to just remove them always and let them be rebuilt
* during the first backend startup.
* Clear out any old relcache cache files. This is *necessary* if we do
* any WAL replay, since that would probably result in the cache files
* being out of sync with database reality. In theory we could leave them
* in place if the database had been cleanly shut down, but it seems
* safest to just remove them always and let them be rebuilt during the
* first backend startup.
*/
RelationCacheInitFileRemove();
@@ -5648,8 +5653,8 @@ StartupXLOG(void)
{
if (recoveryTargetExact)
ereport(LOG,
(errmsg("starting point-in-time recovery to XID %u",
recoveryTargetXid)));
(errmsg("starting point-in-time recovery to XID %u",
recoveryTargetXid)));
else
ereport(LOG,
(errmsg("starting point-in-time recovery to %s",
@@ -5676,6 +5681,7 @@ StartupXLOG(void)
if (XLByteLT(ControlFile->minRecoveryPoint, checkPoint.redo))
ControlFile->minRecoveryPoint = checkPoint.redo;
}
/*
* set backupStartupPoint if we're starting archive recovery from a
* base backup
@@ -5714,14 +5720,14 @@ StartupXLOG(void)
/*
* Initialize recovery connections, if enabled. We won't let backends
* in yet, not until we've reached the min recovery point specified
* in control file and we've established a recovery snapshot from a
* in yet, not until we've reached the min recovery point specified in
* control file and we've established a recovery snapshot from a
* running-xacts WAL record.
*/
if (InArchiveRecovery && XLogRequestRecoveryConnections)
{
TransactionId *xids;
int nxids;
int nxids;
CheckRequiredParameterValues(checkPoint);
@@ -5814,7 +5820,7 @@ StartupXLOG(void)
{
#ifdef WAL_DEBUG
if (XLOG_DEBUG ||
(rmid == RM_XACT_ID && trace_recovery_messages <= DEBUG2) ||
(rmid == RM_XACT_ID && trace_recovery_messages <= DEBUG2) ||
(rmid != RM_XACT_ID && trace_recovery_messages <= DEBUG3))
{
StringInfoData buf;
@@ -5845,14 +5851,14 @@ StartupXLOG(void)
{
reachedMinRecoveryPoint = true;
ereport(LOG,
(errmsg("consistent recovery state reached at %X/%X",
EndRecPtr.xlogid, EndRecPtr.xrecoff)));
(errmsg("consistent recovery state reached at %X/%X",
EndRecPtr.xlogid, EndRecPtr.xrecoff)));
}
/*
* Have we got a valid starting snapshot that will allow
* queries to be run? If so, we can tell postmaster that
* the database is consistent now, enabling connections.
* queries to be run? If so, we can tell postmaster that the
* database is consistent now, enabling connections.
*/
if (standbyState == STANDBY_SNAPSHOT_READY &&
!backendsAllowed &&
@@ -5950,9 +5956,8 @@ StartupXLOG(void)
/*
* We are now done reading the xlog from stream. Turn off streaming
* recovery to force fetching the files (which would be required
* at end of recovery, e.g., timeline history file) from archive or
* pg_xlog.
* recovery to force fetching the files (which would be required at end of
* recovery, e.g., timeline history file) from archive or pg_xlog.
*/
StandbyMode = false;
@@ -6155,8 +6160,8 @@ StartupXLOG(void)
TransactionIdRetreat(ShmemVariableCache->latestCompletedXid);
/*
* Start up the commit log and related stuff, too. In hot standby mode
* we did this already before WAL replay.
* Start up the commit log and related stuff, too. In hot standby mode we
* did this already before WAL replay.
*/
if (standbyState == STANDBY_DISABLED)
{
@@ -6194,7 +6199,7 @@ StartupXLOG(void)
}
/*
* All done. Allow backends to write WAL. (Although the bool flag is
* All done. Allow backends to write WAL. (Although the bool flag is
* probably atomic in itself, we use the info_lck here to ensure that
* there are no race conditions concerning visibility of other recent
* updates to shared memory.)
@@ -6222,9 +6227,9 @@ bool
RecoveryInProgress(void)
{
/*
* We check shared state each time only until we leave recovery mode.
* We can't re-enter recovery, so there's no need to keep checking after
* the shared variable has once been seen false.
* We check shared state each time only until we leave recovery mode. We
* can't re-enter recovery, so there's no need to keep checking after the
* shared variable has once been seen false.
*/
if (!LocalRecoveryInProgress)
return false;
@@ -6241,7 +6246,7 @@ RecoveryInProgress(void)
/*
* Initialize TimeLineID and RedoRecPtr when we discover that recovery
* is finished. InitPostgres() relies upon this behaviour to ensure
* that InitXLOGAccess() is called at backend startup. (If you change
* that InitXLOGAccess() is called at backend startup. (If you change
* this, see also LocalSetXLogInsertAllowed.)
*/
if (!LocalRecoveryInProgress)
@@ -6262,9 +6267,9 @@ bool
XLogInsertAllowed(void)
{
/*
* If value is "unconditionally true" or "unconditionally false",
* just return it. This provides the normal fast path once recovery
* is known done.
* If value is "unconditionally true" or "unconditionally false", just
* return it. This provides the normal fast path once recovery is known
* done.
*/
if (LocalXLogInsertAllowed >= 0)
return (bool) LocalXLogInsertAllowed;
@@ -6276,8 +6281,8 @@ XLogInsertAllowed(void)
return false;
/*
* On exit from recovery, reset to "unconditionally true", since there
* is no need to keep checking.
* On exit from recovery, reset to "unconditionally true", since there is
* no need to keep checking.
*/
LocalXLogInsertAllowed = 1;
return true;
@@ -6938,9 +6943,9 @@ CreateCheckPoint(int flags)
CheckPointGuts(checkPoint.redo, flags);
/*
* Take a snapshot of running transactions and write this to WAL.
* This allows us to reconstruct the state of running transactions
* during archive recovery, if required. Skip, if this info disabled.
* Take a snapshot of running transactions and write this to WAL. This
* allows us to reconstruct the state of running transactions during
* archive recovery, if required. Skip, if this info disabled.
*
* If we are shutting down, or Startup process is completing crash
* recovery we don't need to write running xact data.
@@ -6948,7 +6953,7 @@ CreateCheckPoint(int flags)
* Update checkPoint.nextXid since we have a later value
*/
if (!shutdown && XLogStandbyInfoActive())
LogStandbySnapshot(&checkPoint.oldestActiveXid, &checkPoint.nextXid);
LogStandbySnapshot(&checkPoint.oldestActiveXid, &checkPoint.nextXid);
else
checkPoint.oldestActiveXid = InvalidTransactionId;
@@ -6970,18 +6975,18 @@ CreateCheckPoint(int flags)
XLogFlush(recptr);
/*
* We mustn't write any new WAL after a shutdown checkpoint, or it will
* be overwritten at next startup. No-one should even try, this just
* allows sanity-checking. In the case of an end-of-recovery checkpoint,
* we want to just temporarily disable writing until the system has exited
* We mustn't write any new WAL after a shutdown checkpoint, or it will be
* overwritten at next startup. No-one should even try, this just allows
* sanity-checking. In the case of an end-of-recovery checkpoint, we want
* to just temporarily disable writing until the system has exited
* recovery.
*/
if (shutdown)
{
if (flags & CHECKPOINT_END_OF_RECOVERY)
LocalXLogInsertAllowed = -1; /* return to "check" state */
LocalXLogInsertAllowed = -1; /* return to "check" state */
else
LocalXLogInsertAllowed = 0; /* never again write WAL */
LocalXLogInsertAllowed = 0; /* never again write WAL */
}
/*
@@ -7036,18 +7041,17 @@ CreateCheckPoint(int flags)
smgrpostckpt();
/*
* If there's connected standby servers doing XLOG streaming, don't
* delete XLOG files that have not been streamed to all of them yet.
* This does nothing to prevent them from being deleted when the
* standby is disconnected (e.g because of network problems), but at
* least it avoids an open replication connection from failing because
* of that.
* If there's connected standby servers doing XLOG streaming, don't delete
* XLOG files that have not been streamed to all of them yet. This does
* nothing to prevent them from being deleted when the standby is
* disconnected (e.g because of network problems), but at least it avoids
* an open replication connection from failing because of that.
*/
if ((_logId || _logSeg) && MaxWalSenders > 0)
{
XLogRecPtr oldest;
uint32 log;
uint32 seg;
XLogRecPtr oldest;
uint32 log;
uint32 seg;
oldest = GetOldestWALSendPointer();
if (oldest.xlogid != 0 || oldest.xrecoff != 0)
@@ -7055,15 +7059,15 @@ CreateCheckPoint(int flags)
XLByteToSeg(oldest, log, seg);
if (log < _logId || (log == _logId && seg < _logSeg))
{
_logId = log;
_logSeg = seg;
_logId = log;
_logSeg = seg;
}
}
}
/*
* Delete old log files (those no longer needed even for
* previous checkpoint or the standbys in XLOG streaming).
* Delete old log files (those no longer needed even for previous
* checkpoint or the standbys in XLOG streaming).
*/
if (_logId || _logSeg)
{
@@ -7262,8 +7266,8 @@ CreateRestartPoint(int flags)
/*
* Update pg_control, using current time. Check that it still shows
* IN_ARCHIVE_RECOVERY state and an older checkpoint, else do nothing;
* this is a quick hack to make sure nothing really bad happens if
* somehow we get here after the end-of-recovery checkpoint.
* this is a quick hack to make sure nothing really bad happens if somehow
* we get here after the end-of-recovery checkpoint.
*/
LWLockAcquire(ControlFileLock, LW_EXCLUSIVE);
if (ControlFile->state == DB_IN_ARCHIVE_RECOVERY &&
@@ -7312,9 +7316,9 @@ CreateRestartPoint(int flags)
LogCheckpointEnd(true);
ereport((log_checkpoints ? LOG : DEBUG2),
(errmsg("recovery restart point at %X/%X with latest known log time %s",
lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff,
timestamptz_to_str(GetLatestXLogTime()))));
(errmsg("recovery restart point at %X/%X with latest known log time %s",
lastCheckPoint.redo.xlogid, lastCheckPoint.redo.xrecoff,
timestamptz_to_str(GetLatestXLogTime()))));
LWLockRelease(CheckpointLock);
return true;
@@ -7522,6 +7526,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
else if (info == XLOG_BACKUP_END)
{
XLogRecPtr startpoint;
memcpy(&startpoint, XLogRecGetData(record), sizeof(startpoint));
if (XLByteEQ(ControlFile->backupStartPoint, startpoint))
@@ -7550,12 +7555,12 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
if (InArchiveRecovery)
{
/*
* Note: We don't print the reason string from the record,
* because that gets added as a line using xlog_desc()
* Note: We don't print the reason string from the record, because
* that gets added as a line using xlog_desc()
*/
ereport(WARNING,
(errmsg("unlogged operation performed, data may be missing"),
errhint("This can happen if you temporarily disable archive_mode without taking a new base backup.")));
(errmsg("unlogged operation performed, data may be missing"),
errhint("This can happen if you temporarily disable archive_mode without taking a new base backup.")));
}
}
}
@@ -7601,7 +7606,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
}
else if (info == XLOG_BACKUP_END)
{
XLogRecPtr startpoint;
XLogRecPtr startpoint;
memcpy(&startpoint, rec, sizeof(XLogRecPtr));
appendStringInfo(buf, "backup end: %X/%X",
@@ -7609,7 +7614,7 @@ xlog_desc(StringInfo buf, uint8 xl_info, char *rec)
}
else if (info == XLOG_UNLOGGED)
{
char *reason = rec;
char *reason = rec;
appendStringInfo(buf, "unlogged operation: %s", reason);
}
@@ -7649,7 +7654,7 @@ xlog_outrec(StringInfo buf, XLogRecord *record)
static int
get_sync_bit(int method)
{
int o_direct_flag = 0;
int o_direct_flag = 0;
/* If fsync is disabled, never open in sync mode */
if (!enableFsync)
@@ -7658,11 +7663,11 @@ get_sync_bit(int method)
/*
* Optimize writes by bypassing kernel cache with O_DIRECT when using
* O_SYNC, O_DSYNC or O_FSYNC. But only if archiving and streaming are
* disabled, otherwise the archive command or walsender process will
* read the WAL soon after writing it, which is guaranteed to cause a
* physical read if we bypassed the kernel cache. We also skip the
* posix_fadvise(POSIX_FADV_DONTNEED) call in XLogFileClose() for the
* same reason.
* disabled, otherwise the archive command or walsender process will read
* the WAL soon after writing it, which is guaranteed to cause a physical
* read if we bypassed the kernel cache. We also skip the
* posix_fadvise(POSIX_FADV_DONTNEED) call in XLogFileClose() for the same
* reason.
*
* Never use O_DIRECT in walreceiver process for similar reasons; the WAL
* written by walreceiver is normally read by the startup process soon
@@ -7985,7 +7990,7 @@ pg_stop_backup(PG_FUNCTION_ARGS)
{
XLogRecPtr startpoint;
XLogRecPtr stoppoint;
XLogRecData rdata;
XLogRecData rdata;
pg_time_t stamp_time;
char strfbuf[128];
char histfilepath[MAXPGPATH];
@@ -8132,8 +8137,8 @@ pg_stop_backup(PG_FUNCTION_ARGS)
*
* 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, you can set statement_timeout. Also, some notices
* are issued to clue in anyone who might be doing this interactively.
* wish to wait, you can set statement_timeout. Also, some notices are
* issued to clue in anyone who might be doing this interactively.
*/
XLByteToPrevSeg(stoppoint, _logId, _logSeg);
XLogFileName(lastxlogfilename, ThisTimeLineID, _logId, _logSeg);
@@ -8161,9 +8166,9 @@ pg_stop_backup(PG_FUNCTION_ARGS)
ereport(WARNING,
(errmsg("pg_stop_backup still waiting for all required WAL segments to be archived (%d seconds elapsed)",
waits),
errhint("Check that your archive_command is executing properly. "
"pg_stop_backup can be cancelled safely, "
"but the database backup will not be usable without all the WAL segments.")));
errhint("Check that your archive_command is executing properly. "
"pg_stop_backup can be cancelled safely, "
"but the database backup will not be usable without all the WAL segments.")));
}
}
@@ -8621,6 +8626,7 @@ HandleStartupProcInterrupts(void)
got_SIGHUP = false;
ProcessConfigFile(PGC_SIGHUP);
}
/*
* Check if we were requested to exit without finishing recovery.
*/
@@ -8653,10 +8659,11 @@ StartupProcessMain(void)
*/
pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
if (XLogRequestRecoveryConnections)
pqsignal(SIGALRM, handle_standby_sig_alarm); /* ignored unless InHotStandby */
pqsignal(SIGALRM, handle_standby_sig_alarm); /* ignored unless
* InHotStandby */
else
pqsignal(SIGALRM, SIG_IGN);
pqsignal(SIGPIPE, SIG_IGN);
@@ -8731,20 +8738,20 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
{
if (StandbyMode)
{
bool last_restore_failed = false;
bool last_restore_failed = false;
/*
* In standby mode, wait for the requested record to become
* available, either via restore_command succeeding to restore
* the segment, or via walreceiver having streamed the record.
* available, either via restore_command succeeding to restore the
* segment, or via walreceiver having streamed the record.
*/
for (;;)
{
if (WalRcvInProgress())
{
/*
* While walreceiver is active, wait for new WAL to
* arrive from primary.
* While walreceiver is active, wait for new WAL to arrive
* from primary.
*/
receivedUpto = GetWalRcvWriteRecPtr();
if (XLByteLT(*RecPtr, receivedUpto))
@@ -8798,10 +8805,10 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
/*
* If we succeeded restoring some segments from archive
* since the last connection attempt (or we haven't
* tried streaming yet, retry immediately. But if we
* haven't, assume the problem is persistent, so be
* less aggressive.
* since the last connection attempt (or we haven't tried
* streaming yet, retry immediately. But if we haven't,
* assume the problem is persistent, so be less
* aggressive.
*/
if (last_restore_failed)
{
@@ -8813,7 +8820,7 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
*/
if (CheckForStandbyTrigger())
goto next_record_is_invalid;
pg_usleep(5000000L); /* 5 seconds */
pg_usleep(5000000L); /* 5 seconds */
}
last_restore_failed = true;
@@ -8832,8 +8839,8 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
}
/*
* This possibly-long loop needs to handle interrupts of startup
* process.
* This possibly-long loop needs to handle interrupts of
* startup process.
*/
HandleStartupProcInterrupts();
}
@@ -8857,16 +8864,16 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
}
/*
* At this point, we have the right segment open and we know the
* requested record is in it.
* At this point, we have the right segment open and we know the requested
* record is in it.
*/
Assert(readFile != -1);
/*
* If the current segment is being streamed from master, calculate
* how much of the current page we have received already. We know the
* requested record has been received, but this is for the benefit
* of future calls, to allow quick exit at the top of this function.
* If the current segment is being streamed from master, calculate how
* much of the current page we have received already. We know the
* requested record has been received, but this is for the benefit of
* future calls, to allow quick exit at the top of this function.
*/
if (readStreamed)
{
@@ -8909,16 +8916,16 @@ XLogPageRead(XLogRecPtr *RecPtr, int emode, bool fetching_ckpt,
{
ereport(emode,
(errcode_for_file_access(),
errmsg("could not seek in log file %u, segment %u to offset %u: %m",
readId, readSeg, readOff)));
errmsg("could not seek in log file %u, segment %u to offset %u: %m",
readId, readSeg, readOff)));
goto next_record_is_invalid;
}
if (read(readFile, readBuf, XLOG_BLCKSZ) != XLOG_BLCKSZ)
{
ereport(emode,
(errcode_for_file_access(),
errmsg("could not read from log file %u, segment %u, offset %u: %m",
readId, readSeg, readOff)));
errmsg("could not read from log file %u, segment %u, offset %u: %m",
readId, readSeg, readOff)));
goto next_record_is_invalid;
}
if (!ValidXLOGHeader((XLogPageHeader) readBuf, emode))