mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-12-21 08:29:39 +08:00
Add many new Asserts in code and fix simple bug that slipped through
without them, related to previous commit. Report by Bruce Momjian.
This commit is contained in:
parent
88fba7089e
commit
fd34374b17
@ -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.410 2010/05/13 11:15:38 sriggs Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.411 2010/05/14 07:11:48 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -6009,6 +6009,7 @@ StartupXLOG(void)
|
||||
running.oldestRunningXid = oldestActiveXID;
|
||||
latestCompletedXid = checkPoint.nextXid;
|
||||
TransactionIdRetreat(latestCompletedXid);
|
||||
Assert(TransactionIdIsNormal(latestCompletedXid));
|
||||
running.latestCompletedXid = latestCompletedXid;
|
||||
running.xids = xids;
|
||||
|
||||
@ -7825,6 +7826,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
running.oldestRunningXid = oldestActiveXID;
|
||||
latestCompletedXid = checkPoint.nextXid;
|
||||
TransactionIdRetreat(latestCompletedXid);
|
||||
Assert(TransactionIdIsNormal(latestCompletedXid));
|
||||
running.latestCompletedXid = latestCompletedXid;
|
||||
running.xids = xids;
|
||||
|
||||
|
@ -37,7 +37,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.69 2010/05/13 11:15:38 sriggs Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.70 2010/05/14 07:11:49 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -470,11 +470,13 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
||||
int i;
|
||||
|
||||
Assert(standbyState >= STANDBY_INITIALIZED);
|
||||
Assert(TransactionIdIsValid(running->nextXid));
|
||||
Assert(TransactionIdIsValid(running->oldestRunningXid));
|
||||
Assert(TransactionIdIsNormal(running->latestCompletedXid));
|
||||
|
||||
/*
|
||||
* Remove stale transactions, if any.
|
||||
*/
|
||||
Assert(TransactionIdIsValid(running->oldestRunningXid));
|
||||
ExpireOldKnownAssignedTransactionIds(running->oldestRunningXid);
|
||||
StandbyReleaseOldLocks(running->oldestRunningXid);
|
||||
|
||||
@ -679,6 +681,9 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
||||
if (TransactionIdFollows(nextXid, ShmemVariableCache->nextXid))
|
||||
ShmemVariableCache->nextXid = nextXid;
|
||||
|
||||
Assert(TransactionIdIsNormal(ShmemVariableCache->latestCompletedXid));
|
||||
Assert(TransactionIdIsValid(ShmemVariableCache->nextXid));
|
||||
|
||||
LWLockRelease(ProcArrayLock);
|
||||
|
||||
elog(trace_recovery(DEBUG2), "running transaction data initialized");
|
||||
@ -1502,6 +1507,10 @@ GetRunningTransactionData(void)
|
||||
LWLockRelease(XidGenLock);
|
||||
LWLockRelease(ProcArrayLock);
|
||||
|
||||
Assert(TransactionIdIsValid(CurrentRunningXacts->nextXid));
|
||||
Assert(TransactionIdIsValid(CurrentRunningXacts->oldestRunningXid));
|
||||
Assert(TransactionIdIsNormal(CurrentRunningXacts->latestCompletedXid));
|
||||
|
||||
return CurrentRunningXacts;
|
||||
}
|
||||
|
||||
@ -2317,6 +2326,8 @@ void
|
||||
RecordKnownAssignedTransactionIds(TransactionId xid)
|
||||
{
|
||||
Assert(standbyState >= STANDBY_INITIALIZED);
|
||||
Assert(TransactionIdIsValid(latestObservedXid));
|
||||
Assert(TransactionIdIsValid(xid));
|
||||
|
||||
elog(trace_recovery(DEBUG4), "record known xact %u latestObservedXid %u",
|
||||
xid, latestObservedXid);
|
||||
|
@ -11,7 +11,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.22 2010/05/13 11:15:38 sriggs Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.23 2010/05/14 07:11:49 sriggs Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -717,6 +717,7 @@ standby_redo(XLogRecPtr lsn, XLogRecord *record)
|
||||
running.xcnt = xlrec->xcnt;
|
||||
running.subxid_overflow = xlrec->subxid_overflow;
|
||||
running.nextXid = xlrec->nextXid;
|
||||
running.latestCompletedXid = xlrec->latestCompletedXid;
|
||||
running.oldestRunningXid = xlrec->oldestRunningXid;
|
||||
running.xids = xlrec->xids;
|
||||
|
||||
@ -731,8 +732,9 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
|
||||
{
|
||||
int i;
|
||||
|
||||
appendStringInfo(buf, " nextXid %u oldestRunningXid %u",
|
||||
appendStringInfo(buf, " nextXid %u latestCompletedXid %u oldestRunningXid %u",
|
||||
xlrec->nextXid,
|
||||
xlrec->latestCompletedXid,
|
||||
xlrec->oldestRunningXid);
|
||||
if (xlrec->xcnt > 0)
|
||||
{
|
||||
@ -880,6 +882,7 @@ LogCurrentRunningXacts(RunningTransactions CurrRunningXacts)
|
||||
xlrec.subxid_overflow = CurrRunningXacts->subxid_overflow;
|
||||
xlrec.nextXid = CurrRunningXacts->nextXid;
|
||||
xlrec.oldestRunningXid = CurrRunningXacts->oldestRunningXid;
|
||||
xlrec.latestCompletedXid = CurrRunningXacts->latestCompletedXid;
|
||||
|
||||
/* Header */
|
||||
rdata[0].data = (char *) (&xlrec);
|
||||
@ -902,19 +905,20 @@ LogCurrentRunningXacts(RunningTransactions CurrRunningXacts)
|
||||
|
||||
if (CurrRunningXacts->subxid_overflow)
|
||||
elog(trace_recovery(DEBUG2),
|
||||
"snapshot of %u running transactions overflowed (lsn %X/%X oldest xid %u next xid %u)",
|
||||
"snapshot of %u running transactions overflowed (lsn %X/%X oldest xid %u latest complete %u next xid %u)",
|
||||
CurrRunningXacts->xcnt,
|
||||
recptr.xlogid, recptr.xrecoff,
|
||||
CurrRunningXacts->oldestRunningXid,
|
||||
CurrRunningXacts->latestCompletedXid,
|
||||
CurrRunningXacts->nextXid);
|
||||
else
|
||||
elog(trace_recovery(DEBUG2),
|
||||
"snapshot of %u running transaction ids (lsn %X/%X oldest xid %u next xid %u)",
|
||||
"snapshot of %u running transaction ids (lsn %X/%X oldest xid %u latest complete %u next xid %u)",
|
||||
CurrRunningXacts->xcnt,
|
||||
recptr.xlogid, recptr.xrecoff,
|
||||
CurrRunningXacts->oldestRunningXid,
|
||||
CurrRunningXacts->latestCompletedXid,
|
||||
CurrRunningXacts->nextXid);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user