mirror of
https://github.com/postgres/postgres.git
synced 2025-11-18 02:02:55 +03:00
pgindent run for 8.3.
This commit is contained in:
@@ -14,19 +14,19 @@
|
||||
* CLOG page is initialized to zeroes. Other writes of CLOG come from
|
||||
* recording of transaction commit or abort in xact.c, which generates its
|
||||
* own XLOG records for these events and will re-perform the status update
|
||||
* on redo; so we need make no additional XLOG entry here. For synchronous
|
||||
* on redo; so we need make no additional XLOG entry here. For synchronous
|
||||
* transaction commits, the XLOG is guaranteed flushed through the XLOG commit
|
||||
* record before we are called to log a commit, so the WAL rule "write xlog
|
||||
* before data" is satisfied automatically. However, for async commits we
|
||||
* must track the latest LSN affecting each CLOG page, so that we can flush
|
||||
* XLOG that far and satisfy the WAL rule. We don't have to worry about this
|
||||
* XLOG that far and satisfy the WAL rule. We don't have to worry about this
|
||||
* for aborts (whether sync or async), since the post-crash assumption would
|
||||
* be that such transactions failed anyway.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.44 2007/09/05 18:10:47 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.45 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -60,8 +60,8 @@
|
||||
#define TransactionIdToBIndex(xid) ((xid) % (TransactionId) CLOG_XACTS_PER_BYTE)
|
||||
|
||||
/* We store the latest async LSN for each group of transactions */
|
||||
#define CLOG_XACTS_PER_LSN_GROUP 32 /* keep this a power of 2 */
|
||||
#define CLOG_LSNS_PER_PAGE (CLOG_XACTS_PER_PAGE / CLOG_XACTS_PER_LSN_GROUP)
|
||||
#define CLOG_XACTS_PER_LSN_GROUP 32 /* keep this a power of 2 */
|
||||
#define CLOG_LSNS_PER_PAGE (CLOG_XACTS_PER_PAGE / CLOG_XACTS_PER_LSN_GROUP)
|
||||
|
||||
#define GetLSNIndex(slotno, xid) ((slotno) * CLOG_LSNS_PER_PAGE + \
|
||||
((xid) % (TransactionId) CLOG_XACTS_PER_PAGE) / CLOG_XACTS_PER_LSN_GROUP)
|
||||
@@ -85,7 +85,7 @@ static void WriteTruncateXlogRec(int pageno);
|
||||
* Record the final state of a transaction in the commit log.
|
||||
*
|
||||
* lsn must be the WAL location of the commit record when recording an async
|
||||
* commit. For a synchronous commit it can be InvalidXLogRecPtr, since the
|
||||
* commit. For a synchronous commit it can be InvalidXLogRecPtr, since the
|
||||
* caller guarantees the commit record is already flushed in that case. It
|
||||
* should be InvalidXLogRecPtr for abort cases, too.
|
||||
*
|
||||
@@ -159,7 +159,7 @@ TransactionIdSetStatus(TransactionId xid, XidStatus status, XLogRecPtr lsn)
|
||||
* an LSN that is late enough to be able to guarantee that if we flush up to
|
||||
* that LSN then we will have flushed the transaction's commit record to disk.
|
||||
* The result is not necessarily the exact LSN of the transaction's commit
|
||||
* record! For example, for long-past transactions (those whose clog pages
|
||||
* record! For example, for long-past transactions (those whose clog pages
|
||||
* already migrated to disk), we'll return InvalidXLogRecPtr. Also, because
|
||||
* we group transactions on the same clog page to conserve storage, we might
|
||||
* return the LSN of a later transaction that falls into the same group.
|
||||
@@ -486,8 +486,8 @@ clog_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
memcpy(&pageno, XLogRecGetData(record), sizeof(int));
|
||||
|
||||
/*
|
||||
* During XLOG replay, latest_page_number isn't set up yet; insert
|
||||
* a suitable value to bypass the sanity test in SimpleLruTruncate.
|
||||
* During XLOG replay, latest_page_number isn't set up yet; insert a
|
||||
* suitable value to bypass the sanity test in SimpleLruTruncate.
|
||||
*/
|
||||
ClogCtl->shared->latest_page_number = pageno;
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.25 2007/09/05 18:10:47 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/multixact.c,v 1.26 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -380,9 +380,9 @@ MultiXactIdIsRunning(MultiXactId multi)
|
||||
}
|
||||
|
||||
/*
|
||||
* Checking for myself is cheap compared to looking in shared memory,
|
||||
* so first do the equivalent of MultiXactIdIsCurrent(). This is not
|
||||
* needed for correctness, it's just a fast path.
|
||||
* Checking for myself is cheap compared to looking in shared memory, so
|
||||
* first do the equivalent of MultiXactIdIsCurrent(). This is not needed
|
||||
* for correctness, it's just a fast path.
|
||||
*/
|
||||
for (i = 0; i < nmembers; i++)
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.71 2007/09/08 20:31:14 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/transam.c,v 1.72 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* This file contains the high level access-method interface to the
|
||||
@@ -440,14 +440,14 @@ TransactionId
|
||||
TransactionIdLatest(TransactionId mainxid,
|
||||
int nxids, const TransactionId *xids)
|
||||
{
|
||||
TransactionId result;
|
||||
TransactionId result;
|
||||
|
||||
/*
|
||||
* In practice it is highly likely that the xids[] array is sorted, and
|
||||
* so we could save some cycles by just taking the last child XID, but
|
||||
* this probably isn't so performance-critical that it's worth depending
|
||||
* on that assumption. But just to show we're not totally stupid, scan
|
||||
* the array back-to-front to avoid useless assignments.
|
||||
* In practice it is highly likely that the xids[] array is sorted, and so
|
||||
* we could save some cycles by just taking the last child XID, but this
|
||||
* probably isn't so performance-critical that it's worth depending on
|
||||
* that assumption. But just to show we're not totally stupid, scan the
|
||||
* array back-to-front to avoid useless assignments.
|
||||
*/
|
||||
result = mainxid;
|
||||
while (--nxids >= 0)
|
||||
|
||||
@@ -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.37 2007/10/24 20:55:36 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/twophase.c,v 1.38 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* Each global transaction is associated with a global transaction
|
||||
@@ -397,15 +397,15 @@ LockGXact(const char *gid, Oid user)
|
||||
errhint("Must be superuser or the user that prepared the transaction.")));
|
||||
|
||||
/*
|
||||
* Note: it probably would be possible to allow committing from another
|
||||
* database; but at the moment NOTIFY is known not to work and there
|
||||
* may be some other issues as well. Hence disallow until someone
|
||||
* gets motivated to make it work.
|
||||
* Note: it probably would be possible to allow committing from
|
||||
* another database; but at the moment NOTIFY is known not to work and
|
||||
* there may be some other issues as well. Hence disallow until
|
||||
* someone gets motivated to make it work.
|
||||
*/
|
||||
if (MyDatabaseId != gxact->proc.databaseId)
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||
errmsg("prepared transaction belongs to another database"),
|
||||
errmsg("prepared transaction belongs to another database"),
|
||||
errhint("Connect to the database where the transaction was prepared to finish it.")));
|
||||
|
||||
/* OK for me to lock it */
|
||||
@@ -937,11 +937,11 @@ EndPrepare(GlobalTransaction gxact)
|
||||
* odds of a PANIC actually occurring should be very tiny given that we
|
||||
* were able to write the bogus CRC above.
|
||||
*
|
||||
* We have to set inCommit here, too; otherwise a checkpoint
|
||||
* starting immediately after the WAL record is inserted could complete
|
||||
* without fsync'ing our state file. (This is essentially the same kind
|
||||
* of race condition as the COMMIT-to-clog-write case that
|
||||
* RecordTransactionCommit uses inCommit for; see notes there.)
|
||||
* We have to set inCommit here, too; otherwise a checkpoint starting
|
||||
* immediately after the WAL record is inserted could complete without
|
||||
* fsync'ing our state file. (This is essentially the same kind of race
|
||||
* condition as the COMMIT-to-clog-write case that RecordTransactionCommit
|
||||
* uses inCommit for; see notes there.)
|
||||
*
|
||||
* We save the PREPARE record's location in the gxact for later use by
|
||||
* CheckPointTwoPhase.
|
||||
@@ -985,8 +985,8 @@ EndPrepare(GlobalTransaction gxact)
|
||||
MarkAsPrepared(gxact);
|
||||
|
||||
/*
|
||||
* Now we can mark ourselves as out of the commit critical section:
|
||||
* a checkpoint starting after this will certainly see the gxact as a
|
||||
* Now we can mark ourselves as out of the commit critical section: a
|
||||
* checkpoint starting after this will certainly see the gxact as a
|
||||
* candidate for fsyncing.
|
||||
*/
|
||||
MyProc->inCommit = false;
|
||||
@@ -1272,8 +1272,8 @@ RemoveTwoPhaseFile(TransactionId xid, bool giveWarning)
|
||||
if (errno != ENOENT || giveWarning)
|
||||
ereport(WARNING,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not remove two-phase state file \"%s\": %m",
|
||||
path)));
|
||||
errmsg("could not remove two-phase state file \"%s\": %m",
|
||||
path)));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -1500,8 +1500,8 @@ PrescanPreparedTransactions(void)
|
||||
if (buf == NULL)
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("removing corrupt two-phase state file \"%s\"",
|
||||
clde->d_name)));
|
||||
(errmsg("removing corrupt two-phase state file \"%s\"",
|
||||
clde->d_name)));
|
||||
RemoveTwoPhaseFile(xid, true);
|
||||
continue;
|
||||
}
|
||||
@@ -1511,8 +1511,8 @@ PrescanPreparedTransactions(void)
|
||||
if (!TransactionIdEquals(hdr->xid, xid))
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("removing corrupt two-phase state file \"%s\"",
|
||||
clde->d_name)));
|
||||
(errmsg("removing corrupt two-phase state file \"%s\"",
|
||||
clde->d_name)));
|
||||
RemoveTwoPhaseFile(xid, true);
|
||||
pfree(buf);
|
||||
continue;
|
||||
@@ -1599,8 +1599,8 @@ RecoverPreparedTransactions(void)
|
||||
if (buf == NULL)
|
||||
{
|
||||
ereport(WARNING,
|
||||
(errmsg("removing corrupt two-phase state file \"%s\"",
|
||||
clde->d_name)));
|
||||
(errmsg("removing corrupt two-phase state file \"%s\"",
|
||||
clde->d_name)));
|
||||
RemoveTwoPhaseFile(xid, true);
|
||||
continue;
|
||||
}
|
||||
@@ -1711,9 +1711,9 @@ RecordTransactionCommitPrepared(TransactionId xid,
|
||||
recptr = XLogInsert(RM_XACT_ID, XLOG_XACT_COMMIT_PREPARED, rdata);
|
||||
|
||||
/*
|
||||
* We don't currently try to sleep before flush here ... nor is there
|
||||
* any support for async commit of a prepared xact (the very idea is
|
||||
* probably a contradiction)
|
||||
* We don't currently try to sleep before flush here ... nor is there any
|
||||
* support for async commit of a prepared xact (the very idea is probably
|
||||
* a contradiction)
|
||||
*/
|
||||
|
||||
/* Flush XLOG to disk */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.5 2007/05/27 03:50:39 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/twophase_rmgr.c,v 1.6 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -38,7 +38,7 @@ const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID + 1] =
|
||||
lock_twophase_postcommit, /* Lock */
|
||||
inval_twophase_postcommit, /* Inval */
|
||||
flatfile_twophase_postcommit, /* flat file update */
|
||||
notify_twophase_postcommit, /* notify/listen */
|
||||
notify_twophase_postcommit, /* notify/listen */
|
||||
pgstat_twophase_postcommit /* pgstat */
|
||||
};
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* Copyright (c) 2000-2007, PostgreSQL Global Development Group
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.79 2007/09/08 20:31:14 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/varsup.c,v 1.80 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -73,9 +73,9 @@ GetNewTransactionId(bool isSubXact)
|
||||
TransactionIdIsValid(ShmemVariableCache->xidVacLimit))
|
||||
{
|
||||
/*
|
||||
* To avoid swamping the postmaster with signals, we issue the
|
||||
* autovac request only once per 64K transaction starts. This
|
||||
* still gives plenty of chances before we get into real trouble.
|
||||
* To avoid swamping the postmaster with signals, we issue the autovac
|
||||
* request only once per 64K transaction starts. This still gives
|
||||
* plenty of chances before we get into real trouble.
|
||||
*/
|
||||
if (IsUnderPostmaster && (xid % 65536) == 0)
|
||||
SendPostmasterSignal(PMSIGNAL_START_AUTOVAC_LAUNCHER);
|
||||
@@ -119,9 +119,9 @@ GetNewTransactionId(bool isSubXact)
|
||||
|
||||
/*
|
||||
* We must store the new XID into the shared ProcArray before releasing
|
||||
* XidGenLock. This ensures that every active XID older than
|
||||
* latestCompletedXid is present in the ProcArray, which is essential
|
||||
* for correct OldestXmin tracking; see src/backend/access/transam/README.
|
||||
* XidGenLock. This ensures that every active XID older than
|
||||
* latestCompletedXid is present in the ProcArray, which is essential for
|
||||
* correct OldestXmin tracking; see src/backend/access/transam/README.
|
||||
*
|
||||
* XXX by storing xid into MyProc without acquiring ProcArrayLock, we are
|
||||
* relying on fetch/store of an xid to be atomic, else other backends
|
||||
@@ -249,18 +249,18 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid,
|
||||
xidWarnLimit -= FirstNormalTransactionId;
|
||||
|
||||
/*
|
||||
* We'll start trying to force autovacuums when oldest_datfrozenxid
|
||||
* gets to be more than autovacuum_freeze_max_age transactions old.
|
||||
* We'll start trying to force autovacuums when oldest_datfrozenxid gets
|
||||
* to be more than autovacuum_freeze_max_age transactions old.
|
||||
*
|
||||
* Note: guc.c ensures that autovacuum_freeze_max_age is in a sane
|
||||
* range, so that xidVacLimit will be well before xidWarnLimit.
|
||||
* Note: guc.c ensures that autovacuum_freeze_max_age is in a sane range,
|
||||
* so that xidVacLimit will be well before xidWarnLimit.
|
||||
*
|
||||
* Note: autovacuum_freeze_max_age is a PGC_POSTMASTER parameter so that
|
||||
* we don't have to worry about dealing with on-the-fly changes in its
|
||||
* value. It doesn't look practical to update shared state from a GUC
|
||||
* assign hook (too many processes would try to execute the hook,
|
||||
* resulting in race conditions as well as crashes of those not
|
||||
* connected to shared memory). Perhaps this can be improved someday.
|
||||
* resulting in race conditions as well as crashes of those not connected
|
||||
* to shared memory). Perhaps this can be improved someday.
|
||||
*/
|
||||
xidVacLimit = oldest_datfrozenxid + autovacuum_freeze_max_age;
|
||||
if (xidVacLimit < FirstNormalTransactionId)
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.252 2007/11/10 14:36:44 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xact.c,v 1.253 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -274,8 +274,8 @@ IsTransactionState(void)
|
||||
TransactionState s = CurrentTransactionState;
|
||||
|
||||
/*
|
||||
* TRANS_DEFAULT and TRANS_ABORT are obviously unsafe states. However,
|
||||
* we also reject the startup/shutdown states TRANS_START, TRANS_COMMIT,
|
||||
* TRANS_DEFAULT and TRANS_ABORT are obviously unsafe states. However, we
|
||||
* also reject the startup/shutdown states TRANS_START, TRANS_COMMIT,
|
||||
* TRANS_PREPARE since it might be too soon or too late within those
|
||||
* transition states to do anything interesting. Hence, the only "valid"
|
||||
* state is TRANS_INPROGRESS.
|
||||
@@ -372,7 +372,7 @@ GetCurrentTransactionIdIfAny(void)
|
||||
static void
|
||||
AssignTransactionId(TransactionState s)
|
||||
{
|
||||
bool isSubXact = (s->parent != NULL);
|
||||
bool isSubXact = (s->parent != NULL);
|
||||
ResourceOwner currentOwner;
|
||||
|
||||
/* Assert that caller didn't screw up */
|
||||
@@ -400,9 +400,9 @@ AssignTransactionId(TransactionState s)
|
||||
SubTransSetParent(s->transactionId, s->parent->transactionId);
|
||||
|
||||
/*
|
||||
* Acquire lock on the transaction XID. (We assume this cannot block.)
|
||||
* We have to ensure that the lock is assigned to the transaction's
|
||||
* own ResourceOwner.
|
||||
* Acquire lock on the transaction XID. (We assume this cannot block.) We
|
||||
* have to ensure that the lock is assigned to the transaction's own
|
||||
* ResourceOwner.
|
||||
*/
|
||||
currentOwner = CurrentResourceOwner;
|
||||
PG_TRY();
|
||||
@@ -626,9 +626,9 @@ AtStart_Memory(void)
|
||||
/*
|
||||
* If this is the first time through, create a private context for
|
||||
* AbortTransaction to work in. By reserving some space now, we can
|
||||
* insulate AbortTransaction from out-of-memory scenarios. Like
|
||||
* ErrorContext, we set it up with slow growth rate and a nonzero
|
||||
* minimum size, so that space will be reserved immediately.
|
||||
* insulate AbortTransaction from out-of-memory scenarios. Like
|
||||
* ErrorContext, we set it up with slow growth rate and a nonzero minimum
|
||||
* size, so that space will be reserved immediately.
|
||||
*/
|
||||
if (TransactionAbortContext == NULL)
|
||||
TransactionAbortContext =
|
||||
@@ -749,7 +749,7 @@ AtSubStart_ResourceOwner(void)
|
||||
* RecordTransactionCommit
|
||||
*
|
||||
* Returns latest XID among xact and its children, or InvalidTransactionId
|
||||
* if the xact has no XID. (We compute that here just because it's easier.)
|
||||
* if the xact has no XID. (We compute that here just because it's easier.)
|
||||
*
|
||||
* This is exported only to support an ugly hack in VACUUM FULL.
|
||||
*/
|
||||
@@ -757,7 +757,7 @@ TransactionId
|
||||
RecordTransactionCommit(void)
|
||||
{
|
||||
TransactionId xid = GetTopTransactionIdIfAny();
|
||||
bool markXidCommitted = TransactionIdIsValid(xid);
|
||||
bool markXidCommitted = TransactionIdIsValid(xid);
|
||||
TransactionId latestXid = InvalidTransactionId;
|
||||
int nrels;
|
||||
RelFileNode *rels;
|
||||
@@ -770,29 +770,29 @@ RecordTransactionCommit(void)
|
||||
nchildren = xactGetCommittedChildren(&children);
|
||||
|
||||
/*
|
||||
* If we haven't been assigned an XID yet, we neither can, nor do we
|
||||
* want to write a COMMIT record.
|
||||
* If we haven't been assigned an XID yet, we neither can, nor do we want
|
||||
* to write a COMMIT record.
|
||||
*/
|
||||
if (!markXidCommitted)
|
||||
{
|
||||
/*
|
||||
* We expect that every smgrscheduleunlink is followed by a catalog
|
||||
* update, and hence XID assignment, so we shouldn't get here with
|
||||
* any pending deletes. Use a real test not just an Assert to check
|
||||
* this, since it's a bit fragile.
|
||||
* update, and hence XID assignment, so we shouldn't get here with any
|
||||
* pending deletes. Use a real test not just an Assert to check this,
|
||||
* since it's a bit fragile.
|
||||
*/
|
||||
if (nrels != 0)
|
||||
elog(ERROR, "cannot commit a transaction that deleted files but has no xid");
|
||||
|
||||
/* Can't have child XIDs either; AssignTransactionId enforces this */
|
||||
Assert(nchildren == 0);
|
||||
|
||||
|
||||
/*
|
||||
* If we didn't create XLOG entries, we're done here; otherwise we
|
||||
* should flush those entries the same as a commit record. (An
|
||||
* should flush those entries the same as a commit record. (An
|
||||
* example of a possible record that wouldn't cause an XID to be
|
||||
* assigned is a sequence advance record due to nextval() --- we
|
||||
* want to flush that to disk before reporting commit.)
|
||||
* assigned is a sequence advance record due to nextval() --- we want
|
||||
* to flush that to disk before reporting commit.)
|
||||
*/
|
||||
if (XactLastRecEnd.xrecoff == 0)
|
||||
goto cleanup;
|
||||
@@ -802,30 +802,29 @@ RecordTransactionCommit(void)
|
||||
/*
|
||||
* Begin commit critical section and insert the commit XLOG record.
|
||||
*/
|
||||
XLogRecData rdata[3];
|
||||
int lastrdata = 0;
|
||||
xl_xact_commit xlrec;
|
||||
XLogRecData rdata[3];
|
||||
int lastrdata = 0;
|
||||
xl_xact_commit xlrec;
|
||||
|
||||
/* Tell bufmgr and smgr to prepare for commit */
|
||||
BufmgrCommit();
|
||||
|
||||
/*
|
||||
* Mark ourselves as within our "commit critical section". This
|
||||
* Mark ourselves as within our "commit critical section". This
|
||||
* forces any concurrent checkpoint to wait until we've updated
|
||||
* pg_clog. Without this, it is possible for the checkpoint to
|
||||
* set REDO after the XLOG record but fail to flush the pg_clog
|
||||
* update to disk, leading to loss of the transaction commit if
|
||||
* the system crashes a little later.
|
||||
* pg_clog. Without this, it is possible for the checkpoint to set
|
||||
* REDO after the XLOG record but fail to flush the pg_clog update to
|
||||
* disk, leading to loss of the transaction commit if the system
|
||||
* crashes a little later.
|
||||
*
|
||||
* Note: we could, but don't bother to, set this flag in
|
||||
* RecordTransactionAbort. That's because loss of a transaction
|
||||
* abort is noncritical; the presumption would be that it aborted,
|
||||
* anyway.
|
||||
* RecordTransactionAbort. That's because loss of a transaction abort
|
||||
* is noncritical; the presumption would be that it aborted, anyway.
|
||||
*
|
||||
* It's safe to change the inCommit flag of our own backend
|
||||
* without holding the ProcArrayLock, since we're the only one
|
||||
* modifying it. This makes checkpoint's determination of which
|
||||
* xacts are inCommit a bit fuzzy, but it doesn't matter.
|
||||
* It's safe to change the inCommit flag of our own backend without
|
||||
* holding the ProcArrayLock, since we're the only one modifying it.
|
||||
* This makes checkpoint's determination of which xacts are inCommit a
|
||||
* bit fuzzy, but it doesn't matter.
|
||||
*/
|
||||
START_CRIT_SECTION();
|
||||
MyProc->inCommit = true;
|
||||
@@ -864,7 +863,7 @@ RecordTransactionCommit(void)
|
||||
* Check if we want to commit asynchronously. If the user has set
|
||||
* synchronous_commit = off, and we're not doing cleanup of any non-temp
|
||||
* rels nor committing any command that wanted to force sync commit, then
|
||||
* we can defer flushing XLOG. (We must not allow asynchronous commit if
|
||||
* we can defer flushing XLOG. (We must not allow asynchronous commit if
|
||||
* there are any non-temp tables to be deleted, because we might delete
|
||||
* the files before the COMMIT record is flushed to disk. We do allow
|
||||
* asynchronous commit if all to-be-deleted tables are temporary though,
|
||||
@@ -875,15 +874,14 @@ RecordTransactionCommit(void)
|
||||
/*
|
||||
* Synchronous commit case.
|
||||
*
|
||||
* Sleep before flush! So we can flush more than one commit
|
||||
* records per single fsync. (The idea is some other backend
|
||||
* may do the XLogFlush while we're sleeping. This needs work
|
||||
* still, because on most Unixen, the minimum select() delay
|
||||
* is 10msec or more, which is way too long.)
|
||||
* Sleep before flush! So we can flush more than one commit records
|
||||
* per single fsync. (The idea is some other backend may do the
|
||||
* XLogFlush while we're sleeping. This needs work still, because on
|
||||
* most Unixen, the minimum select() delay is 10msec or more, which is
|
||||
* way too long.)
|
||||
*
|
||||
* We do not sleep if enableFsync is not turned on, nor if
|
||||
* there are fewer than CommitSiblings other backends with
|
||||
* active transactions.
|
||||
* We do not sleep if enableFsync is not turned on, nor if there are
|
||||
* fewer than CommitSiblings other backends with active transactions.
|
||||
*/
|
||||
if (CommitDelay > 0 && enableFsync &&
|
||||
CountActiveBackends() >= CommitSiblings)
|
||||
@@ -906,15 +904,15 @@ RecordTransactionCommit(void)
|
||||
/*
|
||||
* Asynchronous commit case.
|
||||
*
|
||||
* Report the latest async commit LSN, so that
|
||||
* the WAL writer knows to flush this commit.
|
||||
* Report the latest async commit LSN, so that the WAL writer knows to
|
||||
* flush this commit.
|
||||
*/
|
||||
XLogSetAsyncCommitLSN(XactLastRecEnd);
|
||||
|
||||
/*
|
||||
* We must not immediately update the CLOG, since we didn't
|
||||
* flush the XLOG. Instead, we store the LSN up to which
|
||||
* the XLOG must be flushed before the CLOG may be updated.
|
||||
* We must not immediately update the CLOG, since we didn't flush the
|
||||
* XLOG. Instead, we store the LSN up to which the XLOG must be
|
||||
* flushed before the CLOG may be updated.
|
||||
*/
|
||||
if (markXidCommitted)
|
||||
{
|
||||
@@ -925,8 +923,8 @@ RecordTransactionCommit(void)
|
||||
}
|
||||
|
||||
/*
|
||||
* If we entered a commit critical section, leave it now, and
|
||||
* let checkpoints proceed.
|
||||
* If we entered a commit critical section, leave it now, and let
|
||||
* checkpoints proceed.
|
||||
*/
|
||||
if (markXidCommitted)
|
||||
{
|
||||
@@ -1068,11 +1066,11 @@ RecordSubTransactionCommit(void)
|
||||
* We do not log the subcommit in XLOG; it doesn't matter until the
|
||||
* top-level transaction commits.
|
||||
*
|
||||
* We must mark the subtransaction subcommitted in the CLOG if
|
||||
* it had a valid XID assigned. If it did not, nobody else will
|
||||
* ever know about the existence of this subxact. We don't
|
||||
* have to deal with deletions scheduled for on-commit here, since
|
||||
* they'll be reassigned to our parent (who might still abort).
|
||||
* We must mark the subtransaction subcommitted in the CLOG if it had a
|
||||
* valid XID assigned. If it did not, nobody else will ever know about
|
||||
* the existence of this subxact. We don't have to deal with deletions
|
||||
* scheduled for on-commit here, since they'll be reassigned to our parent
|
||||
* (who might still abort).
|
||||
*/
|
||||
if (TransactionIdIsValid(xid))
|
||||
{
|
||||
@@ -1095,7 +1093,7 @@ RecordSubTransactionCommit(void)
|
||||
* RecordTransactionAbort
|
||||
*
|
||||
* Returns latest XID among xact and its children, or InvalidTransactionId
|
||||
* if the xact has no XID. (We compute that here just because it's easier.)
|
||||
* if the xact has no XID. (We compute that here just because it's easier.)
|
||||
*/
|
||||
static TransactionId
|
||||
RecordTransactionAbort(bool isSubXact)
|
||||
@@ -1106,15 +1104,15 @@ RecordTransactionAbort(bool isSubXact)
|
||||
RelFileNode *rels;
|
||||
int nchildren;
|
||||
TransactionId *children;
|
||||
XLogRecData rdata[3];
|
||||
int lastrdata = 0;
|
||||
xl_xact_abort xlrec;
|
||||
XLogRecData rdata[3];
|
||||
int lastrdata = 0;
|
||||
xl_xact_abort xlrec;
|
||||
|
||||
/*
|
||||
* If we haven't been assigned an XID, nobody will care whether we
|
||||
* aborted or not. Hence, we're done in that case. It does not matter
|
||||
* if we have rels to delete (note that this routine is not responsible
|
||||
* for actually deleting 'em). We cannot have any child XIDs, either.
|
||||
* If we haven't been assigned an XID, nobody will care whether we aborted
|
||||
* or not. Hence, we're done in that case. It does not matter if we have
|
||||
* rels to delete (note that this routine is not responsible for actually
|
||||
* deleting 'em). We cannot have any child XIDs, either.
|
||||
*/
|
||||
if (!TransactionIdIsValid(xid))
|
||||
{
|
||||
@@ -1128,7 +1126,7 @@ RecordTransactionAbort(bool isSubXact)
|
||||
* We have a valid XID, so we should write an ABORT record for it.
|
||||
*
|
||||
* We do not flush XLOG to disk here, since the default assumption after a
|
||||
* crash would be that we aborted, anyway. For the same reason, we don't
|
||||
* crash would be that we aborted, anyway. For the same reason, we don't
|
||||
* need to worry about interlocking against checkpoint start.
|
||||
*/
|
||||
|
||||
@@ -1189,10 +1187,10 @@ RecordTransactionAbort(bool isSubXact)
|
||||
* having flushed the ABORT record to disk, because in event of a crash
|
||||
* we'd be assumed to have aborted anyway.
|
||||
*
|
||||
* The ordering here isn't critical but it seems best to mark the
|
||||
* parent first. This assures an atomic transition of all the
|
||||
* subtransactions to aborted state from the point of view of
|
||||
* concurrent TransactionIdDidAbort calls.
|
||||
* The ordering here isn't critical but it seems best to mark the parent
|
||||
* first. This assures an atomic transition of all the subtransactions to
|
||||
* aborted state from the point of view of concurrent
|
||||
* TransactionIdDidAbort calls.
|
||||
*/
|
||||
TransactionIdAbort(xid);
|
||||
TransactionIdAbortTree(nchildren, children);
|
||||
@@ -1231,9 +1229,9 @@ static void
|
||||
AtAbort_Memory(void)
|
||||
{
|
||||
/*
|
||||
* Switch into TransactionAbortContext, which should have some free
|
||||
* space even if nothing else does. We'll work in this context until
|
||||
* we've finished cleaning up.
|
||||
* Switch into TransactionAbortContext, which should have some free space
|
||||
* even if nothing else does. We'll work in this context until we've
|
||||
* finished cleaning up.
|
||||
*
|
||||
* It is barely possible to get here when we've not been able to create
|
||||
* TransactionAbortContext yet; if so use TopMemoryContext.
|
||||
@@ -1438,7 +1436,7 @@ StartTransaction(void)
|
||||
VirtualXactLockTableInsert(vxid);
|
||||
|
||||
/*
|
||||
* Advertise it in the proc array. We assume assignment of
|
||||
* Advertise it in the proc array. We assume assignment of
|
||||
* LocalTransactionID is atomic, and the backendId should be set already.
|
||||
*/
|
||||
Assert(MyProc->backendId == vxid.backendId);
|
||||
@@ -1449,8 +1447,8 @@ StartTransaction(void)
|
||||
/*
|
||||
* set transaction_timestamp() (a/k/a now()). We want this to be the same
|
||||
* as the first command's statement_timestamp(), so don't do a fresh
|
||||
* GetCurrentTimestamp() call (which'd be expensive anyway). Also,
|
||||
* mark xactStopTimestamp as unset.
|
||||
* GetCurrentTimestamp() call (which'd be expensive anyway). Also, mark
|
||||
* xactStopTimestamp as unset.
|
||||
*/
|
||||
xactStartTimestamp = stmtStartTimestamp;
|
||||
xactStopTimestamp = 0;
|
||||
@@ -1576,8 +1574,8 @@ CommitTransaction(void)
|
||||
PG_TRACE1(transaction__commit, MyProc->lxid);
|
||||
|
||||
/*
|
||||
* Let others know about no transaction in progress by me. Note that
|
||||
* this must be done _before_ releasing locks we hold and _after_
|
||||
* Let others know about no transaction in progress by me. Note that this
|
||||
* must be done _before_ releasing locks we hold and _after_
|
||||
* RecordTransactionCommit.
|
||||
*/
|
||||
ProcArrayEndTransaction(MyProc, latestXid);
|
||||
@@ -2503,7 +2501,7 @@ AbortCurrentTransaction(void)
|
||||
* inside a function or multi-query querystring. (We will always fail if
|
||||
* this is false, but it's convenient to centralize the check here instead of
|
||||
* making callers do it.)
|
||||
* stmtType: statement type name, for error messages.
|
||||
* stmtType: statement type name, for error messages.
|
||||
*/
|
||||
void
|
||||
PreventTransactionChain(bool isTopLevel, const char *stmtType)
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1996-2007, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.287 2007/11/15 20:36:40 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.288 2007/11/15 21:14:32 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -80,7 +80,7 @@ bool XLOG_DEBUG = false;
|
||||
* future XLOG segment as long as there aren't already XLOGfileslop future
|
||||
* segments; else we'll delete it. This could be made a separate GUC
|
||||
* variable, but at present I think it's sufficient to hardwire it as
|
||||
* 2*CheckPointSegments+1. Under normal conditions, a checkpoint will free
|
||||
* 2*CheckPointSegments+1. Under normal conditions, a checkpoint will free
|
||||
* no more than 2*CheckPointSegments log segments, and we want to recycle all
|
||||
* of them; the +1 allows boundary cases to happen without wasting a
|
||||
* delete/create-segment cycle.
|
||||
@@ -287,7 +287,7 @@ typedef struct XLogCtlData
|
||||
XLogwrtResult LogwrtResult;
|
||||
uint32 ckptXidEpoch; /* nextXID & epoch of latest checkpoint */
|
||||
TransactionId ckptXid;
|
||||
XLogRecPtr asyncCommitLSN; /* LSN of newest async commit */
|
||||
XLogRecPtr asyncCommitLSN; /* LSN of newest async commit */
|
||||
|
||||
/* Protected by WALWriteLock: */
|
||||
XLogCtlWrite Write;
|
||||
@@ -737,8 +737,8 @@ begin:;
|
||||
* full-block records into the non-full-block format.
|
||||
*
|
||||
* Note: we could just set the flag whenever !forcePageWrites, but
|
||||
* defining it like this leaves the info bit free for some potential
|
||||
* other use in records without any backup blocks.
|
||||
* defining it like this leaves the info bit free for some potential other
|
||||
* use in records without any backup blocks.
|
||||
*/
|
||||
if ((info & XLR_BKP_BLOCK_MASK) && !Insert->forcePageWrites)
|
||||
info |= XLR_BKP_REMOVABLE;
|
||||
@@ -1345,10 +1345,10 @@ static bool
|
||||
XLogCheckpointNeeded(void)
|
||||
{
|
||||
/*
|
||||
* A straight computation of segment number could overflow 32
|
||||
* bits. Rather than assuming we have working 64-bit
|
||||
* arithmetic, we compare the highest-order bits separately,
|
||||
* and force a checkpoint immediately when they change.
|
||||
* A straight computation of segment number could overflow 32 bits.
|
||||
* Rather than assuming we have working 64-bit arithmetic, we compare the
|
||||
* highest-order bits separately, and force a checkpoint immediately when
|
||||
* they change.
|
||||
*/
|
||||
uint32 old_segno,
|
||||
new_segno;
|
||||
@@ -1361,7 +1361,7 @@ XLogCheckpointNeeded(void)
|
||||
new_segno = (openLogId % XLogSegSize) * XLogSegsPerFile + openLogSeg;
|
||||
new_highbits = openLogId / XLogSegSize;
|
||||
if (new_highbits != old_highbits ||
|
||||
new_segno >= old_segno + (uint32) (CheckPointSegments-1))
|
||||
new_segno >= old_segno + (uint32) (CheckPointSegments - 1))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -1558,9 +1558,9 @@ XLogWrite(XLogwrtRqst WriteRqst, bool flexible, bool xlog_switch)
|
||||
/*
|
||||
* Signal bgwriter to start a checkpoint if we've consumed too
|
||||
* much xlog since the last one. For speed, we first check
|
||||
* using the local copy of RedoRecPtr, which might be
|
||||
* out of date; if it looks like a checkpoint is needed,
|
||||
* forcibly update RedoRecPtr and recheck.
|
||||
* using the local copy of RedoRecPtr, which might be out of
|
||||
* date; if it looks like a checkpoint is needed, forcibly
|
||||
* update RedoRecPtr and recheck.
|
||||
*/
|
||||
if (IsUnderPostmaster &&
|
||||
XLogCheckpointNeeded())
|
||||
@@ -1779,9 +1779,9 @@ XLogFlush(XLogRecPtr record)
|
||||
* We normally flush only completed blocks; but if there is nothing to do on
|
||||
* that basis, we check for unflushed async commits in the current incomplete
|
||||
* block, and flush through the latest one of those. Thus, if async commits
|
||||
* are not being used, we will flush complete blocks only. We can guarantee
|
||||
* are not being used, we will flush complete blocks only. We can guarantee
|
||||
* that async commits reach disk after at most three cycles; normally only
|
||||
* one or two. (We allow XLogWrite to write "flexibly", meaning it can stop
|
||||
* one or two. (We allow XLogWrite to write "flexibly", meaning it can stop
|
||||
* at the end of the buffer ring; this makes a difference only with very high
|
||||
* load or long wal_writer_delay, but imposes one extra cycle for the worst
|
||||
* case for async commits.)
|
||||
@@ -1861,6 +1861,7 @@ void
|
||||
XLogAsyncCommitFlush(void)
|
||||
{
|
||||
XLogRecPtr WriteRqstPtr;
|
||||
|
||||
/* use volatile pointer to prevent code rearrangement */
|
||||
volatile XLogCtlData *xlogctl = XLogCtl;
|
||||
|
||||
@@ -2252,7 +2253,7 @@ InstallXLogFileSegment(uint32 *log, uint32 *seg, char *tmppath,
|
||||
LWLockRelease(ControlFileLock);
|
||||
return false;
|
||||
}
|
||||
#endif /* WIN32 */
|
||||
#endif /* WIN32 */
|
||||
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
@@ -2432,8 +2433,8 @@ RestoreArchivedFile(char *path, const char *xlogfname,
|
||||
int rc;
|
||||
bool signaled;
|
||||
struct stat stat_buf;
|
||||
uint32 restartLog;
|
||||
uint32 restartSeg;
|
||||
uint32 restartLog;
|
||||
uint32 restartSeg;
|
||||
|
||||
/*
|
||||
* When doing archive recovery, we always prefer an archived log file even
|
||||
@@ -2511,8 +2512,8 @@ RestoreArchivedFile(char *path, const char *xlogfname,
|
||||
sp++;
|
||||
XLByteToSeg(ControlFile->checkPointCopy.redo,
|
||||
restartLog, restartSeg);
|
||||
XLogFileName(lastRestartPointFname,
|
||||
ControlFile->checkPointCopy.ThisTimeLineID,
|
||||
XLogFileName(lastRestartPointFname,
|
||||
ControlFile->checkPointCopy.ThisTimeLineID,
|
||||
restartLog, restartSeg);
|
||||
StrNCpy(dp, lastRestartPointFname, endp - dp);
|
||||
dp += strlen(dp);
|
||||
@@ -2594,17 +2595,17 @@ RestoreArchivedFile(char *path, const char *xlogfname,
|
||||
* incorrectly. We have to assume the former.
|
||||
*
|
||||
* However, if the failure was due to any sort of signal, it's best to
|
||||
* punt and abort recovery. (If we "return false" here, upper levels
|
||||
* will assume that recovery is complete and start up the database!)
|
||||
* It's essential to abort on child SIGINT and SIGQUIT, because per spec
|
||||
* punt and abort recovery. (If we "return false" here, upper levels will
|
||||
* assume that recovery is complete and start up the database!) It's
|
||||
* essential to abort on child SIGINT and SIGQUIT, because per spec
|
||||
* system() ignores SIGINT and SIGQUIT while waiting; if we see one of
|
||||
* those it's a good bet we should have gotten it too. Aborting on other
|
||||
* signals such as SIGTERM seems a good idea as well.
|
||||
*
|
||||
* Per the Single Unix Spec, shells report exit status > 128 when
|
||||
* a called command died on a signal. Also, 126 and 127 are used to
|
||||
* report problems such as an unfindable command; treat those as fatal
|
||||
* errors too.
|
||||
* Per the Single Unix Spec, shells report exit status > 128 when a called
|
||||
* command died on a signal. Also, 126 and 127 are used to report
|
||||
* problems such as an unfindable command; treat those as fatal errors
|
||||
* too.
|
||||
*/
|
||||
signaled = WIFSIGNALED(rc) || WEXITSTATUS(rc) > 125;
|
||||
|
||||
@@ -3981,8 +3982,8 @@ ReadControlFile(void)
|
||||
ereport(FATAL,
|
||||
(errmsg("database files are incompatible with server"),
|
||||
errdetail("The database cluster was initialized with TOAST_MAX_CHUNK_SIZE %d,"
|
||||
" but the server was compiled with TOAST_MAX_CHUNK_SIZE %d.",
|
||||
ControlFile->toast_max_chunk_size, (int) TOAST_MAX_CHUNK_SIZE),
|
||||
" but the server was compiled with TOAST_MAX_CHUNK_SIZE %d.",
|
||||
ControlFile->toast_max_chunk_size, (int) TOAST_MAX_CHUNK_SIZE),
|
||||
errhint("It looks like you need to recompile or initdb.")));
|
||||
|
||||
#ifdef HAVE_INT64_TIMESTAMP
|
||||
@@ -4430,7 +4431,7 @@ readRecoveryCommandFile(void)
|
||||
*/
|
||||
recoveryTargetTime =
|
||||
DatumGetTimestampTz(DirectFunctionCall3(timestamptz_in,
|
||||
CStringGetDatum(tok2),
|
||||
CStringGetDatum(tok2),
|
||||
ObjectIdGetDatum(InvalidOid),
|
||||
Int32GetDatum(-1)));
|
||||
ereport(LOG,
|
||||
@@ -4629,7 +4630,7 @@ recoveryStopsHere(XLogRecord *record, bool *includeThis)
|
||||
{
|
||||
bool stopsHere;
|
||||
uint8 record_info;
|
||||
TimestampTz recordXtime;
|
||||
TimestampTz recordXtime;
|
||||
|
||||
/* We only consider stopping at COMMIT or ABORT records */
|
||||
if (record->xl_rmid != RM_XACT_ID)
|
||||
@@ -4781,11 +4782,11 @@ StartupXLOG(void)
|
||||
(errmsg("database system was interrupted while in recovery at log time %s",
|
||||
str_time(ControlFile->checkPointCopy.time)),
|
||||
errhint("If this has occurred more than once some data might be corrupted"
|
||||
" and you might need to choose an earlier recovery target.")));
|
||||
" and you might need to choose an earlier recovery target.")));
|
||||
else if (ControlFile->state == DB_IN_PRODUCTION)
|
||||
ereport(LOG,
|
||||
(errmsg("database system was interrupted; last known up at %s",
|
||||
str_time(ControlFile->time))));
|
||||
(errmsg("database system was interrupted; last known up at %s",
|
||||
str_time(ControlFile->time))));
|
||||
|
||||
/* This is just to allow attaching to startup process with a debugger */
|
||||
#ifdef XLOG_REPLAY_DELAY
|
||||
@@ -4879,9 +4880,9 @@ StartupXLOG(void)
|
||||
wasShutdown = (record->xl_info == XLOG_CHECKPOINT_SHUTDOWN);
|
||||
|
||||
ereport(DEBUG1,
|
||||
(errmsg("redo record is at %X/%X; shutdown %s",
|
||||
checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
|
||||
wasShutdown ? "TRUE" : "FALSE")));
|
||||
(errmsg("redo record is at %X/%X; shutdown %s",
|
||||
checkPoint.redo.xlogid, checkPoint.redo.xrecoff,
|
||||
wasShutdown ? "TRUE" : "FALSE")));
|
||||
ereport(DEBUG1,
|
||||
(errmsg("next transaction ID: %u/%u; next OID: %u",
|
||||
checkPoint.nextXidEpoch, checkPoint.nextXid,
|
||||
@@ -4920,7 +4921,7 @@ StartupXLOG(void)
|
||||
{
|
||||
if (wasShutdown)
|
||||
ereport(PANIC,
|
||||
(errmsg("invalid redo record in shutdown checkpoint")));
|
||||
(errmsg("invalid redo record in shutdown checkpoint")));
|
||||
InRecovery = true;
|
||||
}
|
||||
else if (ControlFile->state != DB_SHUTDOWNED)
|
||||
@@ -5045,7 +5046,7 @@ StartupXLOG(void)
|
||||
*/
|
||||
if (recoveryStopsHere(record, &recoveryApply))
|
||||
{
|
||||
reachedStopPoint = true; /* see below */
|
||||
reachedStopPoint = true; /* see below */
|
||||
recoveryContinue = false;
|
||||
if (!recoveryApply)
|
||||
break;
|
||||
@@ -5087,8 +5088,8 @@ StartupXLOG(void)
|
||||
ReadRecPtr.xlogid, ReadRecPtr.xrecoff)));
|
||||
if (recoveryLastXTime)
|
||||
ereport(LOG,
|
||||
(errmsg("last completed transaction was at log time %s",
|
||||
timestamptz_to_str(recoveryLastXTime))));
|
||||
(errmsg("last completed transaction was at log time %s",
|
||||
timestamptz_to_str(recoveryLastXTime))));
|
||||
InRedo = false;
|
||||
}
|
||||
else
|
||||
@@ -5116,7 +5117,7 @@ StartupXLOG(void)
|
||||
if (reachedStopPoint) /* stopped because of stop request */
|
||||
ereport(FATAL,
|
||||
(errmsg("requested recovery stop point is before end time of backup dump")));
|
||||
else /* ran off end of WAL */
|
||||
else /* ran off end of WAL */
|
||||
ereport(FATAL,
|
||||
(errmsg("WAL ends before end time of backup dump")));
|
||||
}
|
||||
@@ -5124,12 +5125,12 @@ StartupXLOG(void)
|
||||
/*
|
||||
* Consider whether we need to assign a new timeline ID.
|
||||
*
|
||||
* If we are doing an archive recovery, we always assign a new ID. This
|
||||
* handles a couple of issues. If we stopped short of the end of WAL
|
||||
* If we are doing an archive recovery, we always assign a new ID. This
|
||||
* handles a couple of issues. If we stopped short of the end of WAL
|
||||
* during recovery, then we are clearly generating a new timeline and must
|
||||
* assign it a unique new ID. Even if we ran to the end, modifying the
|
||||
* current last segment is problematic because it may result in trying
|
||||
* to overwrite an already-archived copy of that segment, and we encourage
|
||||
* current last segment is problematic because it may result in trying to
|
||||
* overwrite an already-archived copy of that segment, and we encourage
|
||||
* DBAs to make their archive_commands reject that. We can dodge the
|
||||
* problem by making the new active segment have a new timeline ID.
|
||||
*
|
||||
@@ -5472,7 +5473,7 @@ GetInsertRecPtr(void)
|
||||
{
|
||||
/* use volatile pointer to prevent code rearrangement */
|
||||
volatile XLogCtlData *xlogctl = XLogCtl;
|
||||
XLogRecPtr recptr;
|
||||
XLogRecPtr recptr;
|
||||
|
||||
SpinLockAcquire(&xlogctl->info_lck);
|
||||
recptr = xlogctl->LogwrtRqst.Write;
|
||||
@@ -5576,8 +5577,12 @@ LogCheckpointStart(int flags)
|
||||
static void
|
||||
LogCheckpointEnd(void)
|
||||
{
|
||||
long write_secs, sync_secs, total_secs;
|
||||
int write_usecs, sync_usecs, total_usecs;
|
||||
long write_secs,
|
||||
sync_secs,
|
||||
total_secs;
|
||||
int write_usecs,
|
||||
sync_usecs,
|
||||
total_usecs;
|
||||
|
||||
CheckpointStats.ckpt_end_t = GetCurrentTimestamp();
|
||||
|
||||
@@ -5601,9 +5606,9 @@ LogCheckpointEnd(void)
|
||||
CheckpointStats.ckpt_segs_added,
|
||||
CheckpointStats.ckpt_segs_removed,
|
||||
CheckpointStats.ckpt_segs_recycled,
|
||||
write_secs, write_usecs/1000,
|
||||
sync_secs, sync_usecs/1000,
|
||||
total_secs, total_usecs/1000);
|
||||
write_secs, write_usecs / 1000,
|
||||
sync_secs, sync_usecs / 1000,
|
||||
total_secs, total_usecs / 1000);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -5665,9 +5670,9 @@ CreateCheckPoint(int flags)
|
||||
}
|
||||
|
||||
/*
|
||||
* Let smgr prepare for checkpoint; this has to happen before we
|
||||
* determine the REDO pointer. Note that smgr must not do anything
|
||||
* that'd have to be undone if we decide no checkpoint is needed.
|
||||
* Let smgr prepare for checkpoint; this has to happen before we determine
|
||||
* the REDO pointer. Note that smgr must not do anything that'd have to
|
||||
* be undone if we decide no checkpoint is needed.
|
||||
*/
|
||||
smgrpreckpt();
|
||||
|
||||
@@ -5761,8 +5766,8 @@ CreateCheckPoint(int flags)
|
||||
LWLockRelease(WALInsertLock);
|
||||
|
||||
/*
|
||||
* If enabled, log checkpoint start. We postpone this until now
|
||||
* so as not to log anything if we decided to skip the checkpoint.
|
||||
* If enabled, log checkpoint start. We postpone this until now so as not
|
||||
* to log anything if we decided to skip the checkpoint.
|
||||
*/
|
||||
if (log_checkpoints)
|
||||
LogCheckpointStart(flags);
|
||||
@@ -5782,11 +5787,11 @@ CreateCheckPoint(int flags)
|
||||
* checkpoint take a bit longer than to hold locks longer than necessary.
|
||||
* (In fact, the whole reason we have this issue is that xact.c does
|
||||
* commit record XLOG insertion and clog update as two separate steps
|
||||
* protected by different locks, but again that seems best on grounds
|
||||
* of minimizing lock contention.)
|
||||
* protected by different locks, but again that seems best on grounds of
|
||||
* minimizing lock contention.)
|
||||
*
|
||||
* A transaction that has not yet set inCommit when we look cannot be
|
||||
* at risk, since he's not inserted his commit record yet; and one that's
|
||||
* A transaction that has not yet set inCommit when we look cannot be at
|
||||
* risk, since he's not inserted his commit record yet; and one that's
|
||||
* already cleared it is not at risk either, since he's done fixing clog
|
||||
* and we will correctly flush the update below. So we cannot miss any
|
||||
* xacts we need to wait for.
|
||||
@@ -5794,8 +5799,9 @@ CreateCheckPoint(int flags)
|
||||
nInCommit = GetTransactionsInCommit(&inCommitXids);
|
||||
if (nInCommit > 0)
|
||||
{
|
||||
do {
|
||||
pg_usleep(10000L); /* wait for 10 msec */
|
||||
do
|
||||
{
|
||||
pg_usleep(10000L); /* wait for 10 msec */
|
||||
} while (HaveTransactionsInCommit(inCommitXids, nInCommit));
|
||||
}
|
||||
pfree(inCommitXids);
|
||||
@@ -5946,7 +5952,7 @@ CheckPointGuts(XLogRecPtr checkPointRedo, int flags)
|
||||
CheckPointCLOG();
|
||||
CheckPointSUBTRANS();
|
||||
CheckPointMultiXact();
|
||||
CheckPointBuffers(flags); /* performs all required fsyncs */
|
||||
CheckPointBuffers(flags); /* performs all required fsyncs */
|
||||
/* We deliberately delay 2PC checkpointing as long as possible */
|
||||
CheckPointTwoPhase(checkPointRedo);
|
||||
}
|
||||
@@ -6046,14 +6052,14 @@ XLogPutNextOid(Oid nextOid)
|
||||
* does.
|
||||
*
|
||||
* Note, however, that the above statement only covers state "within" the
|
||||
* database. When we use a generated OID as a file or directory name,
|
||||
* we are in a sense violating the basic WAL rule, because that filesystem
|
||||
* database. When we use a generated OID as a file or directory name, we
|
||||
* are in a sense violating the basic WAL rule, because that filesystem
|
||||
* change may reach disk before the NEXTOID WAL record does. The impact
|
||||
* of this is that if a database crash occurs immediately afterward,
|
||||
* we might after restart re-generate the same OID and find that it
|
||||
* conflicts with the leftover file or directory. But since for safety's
|
||||
* sake we always loop until finding a nonconflicting filename, this poses
|
||||
* no real problem in practice. See pgsql-hackers discussion 27-Sep-2006.
|
||||
* of this is that if a database crash occurs immediately afterward, we
|
||||
* might after restart re-generate the same OID and find that it conflicts
|
||||
* with the leftover file or directory. But since for safety's sake we
|
||||
* always loop until finding a nonconflicting filename, this poses no real
|
||||
* problem in practice. See pgsql-hackers discussion 27-Sep-2006.
|
||||
*/
|
||||
}
|
||||
|
||||
@@ -6673,7 +6679,7 @@ pg_switch_xlog(PG_FUNCTION_ARGS)
|
||||
if (!superuser())
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
|
||||
(errmsg("must be superuser to switch transaction log files"))));
|
||||
(errmsg("must be superuser to switch transaction log files"))));
|
||||
|
||||
switchpoint = RequestXLogSwitch();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user