Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfd34374

Browse files
Add many new Asserts in code and fix simple bug that slipped through
without them, related to previous commit. Report by Bruce Momjian.
1 parent88fba70 commitfd34374

File tree

3 files changed

+25
-8
lines changed

3 files changed

+25
-8
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.410 2010/05/1311:15:38 sriggs Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.411 2010/05/14 07:11:48 sriggs Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -6009,6 +6009,7 @@ StartupXLOG(void)
60096009
running.oldestRunningXid=oldestActiveXID;
60106010
latestCompletedXid=checkPoint.nextXid;
60116011
TransactionIdRetreat(latestCompletedXid);
6012+
Assert(TransactionIdIsNormal(latestCompletedXid));
60126013
running.latestCompletedXid=latestCompletedXid;
60136014
running.xids=xids;
60146015

@@ -7825,6 +7826,7 @@ xlog_redo(XLogRecPtr lsn, XLogRecord *record)
78257826
running.oldestRunningXid=oldestActiveXID;
78267827
latestCompletedXid=checkPoint.nextXid;
78277828
TransactionIdRetreat(latestCompletedXid);
7829+
Assert(TransactionIdIsNormal(latestCompletedXid));
78287830
running.latestCompletedXid=latestCompletedXid;
78297831
running.xids=xids;
78307832

‎src/backend/storage/ipc/procarray.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
*
3838
*
3939
* IDENTIFICATION
40-
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.69 2010/05/1311:15:38 sriggs Exp $
40+
* $PostgreSQL: pgsql/src/backend/storage/ipc/procarray.c,v 1.70 2010/05/14 07:11:49 sriggs Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -470,11 +470,13 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
470470
inti;
471471

472472
Assert(standbyState >=STANDBY_INITIALIZED);
473+
Assert(TransactionIdIsValid(running->nextXid));
474+
Assert(TransactionIdIsValid(running->oldestRunningXid));
475+
Assert(TransactionIdIsNormal(running->latestCompletedXid));
473476

474477
/*
475478
* Remove stale transactions, if any.
476479
*/
477-
Assert(TransactionIdIsValid(running->oldestRunningXid));
478480
ExpireOldKnownAssignedTransactionIds(running->oldestRunningXid);
479481
StandbyReleaseOldLocks(running->oldestRunningXid);
480482

@@ -679,6 +681,9 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
679681
if (TransactionIdFollows(nextXid,ShmemVariableCache->nextXid))
680682
ShmemVariableCache->nextXid=nextXid;
681683

684+
Assert(TransactionIdIsNormal(ShmemVariableCache->latestCompletedXid));
685+
Assert(TransactionIdIsValid(ShmemVariableCache->nextXid));
686+
682687
LWLockRelease(ProcArrayLock);
683688

684689
elog(trace_recovery(DEBUG2),"running transaction data initialized");
@@ -1502,6 +1507,10 @@ GetRunningTransactionData(void)
15021507
LWLockRelease(XidGenLock);
15031508
LWLockRelease(ProcArrayLock);
15041509

1510+
Assert(TransactionIdIsValid(CurrentRunningXacts->nextXid));
1511+
Assert(TransactionIdIsValid(CurrentRunningXacts->oldestRunningXid));
1512+
Assert(TransactionIdIsNormal(CurrentRunningXacts->latestCompletedXid));
1513+
15051514
returnCurrentRunningXacts;
15061515
}
15071516

@@ -2317,6 +2326,8 @@ void
23172326
RecordKnownAssignedTransactionIds(TransactionIdxid)
23182327
{
23192328
Assert(standbyState >=STANDBY_INITIALIZED);
2329+
Assert(TransactionIdIsValid(latestObservedXid));
2330+
Assert(TransactionIdIsValid(xid));
23202331

23212332
elog(trace_recovery(DEBUG4),"record known xact %u latestObservedXid %u",
23222333
xid,latestObservedXid);

‎src/backend/storage/ipc/standby.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1994, Regents of the University of California
1212
*
1313
* IDENTIFICATION
14-
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.22 2010/05/1311:15:38 sriggs Exp $
14+
* $PostgreSQL: pgsql/src/backend/storage/ipc/standby.c,v 1.23 2010/05/14 07:11:49 sriggs Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -717,6 +717,7 @@ standby_redo(XLogRecPtr lsn, XLogRecord *record)
717717
running.xcnt=xlrec->xcnt;
718718
running.subxid_overflow=xlrec->subxid_overflow;
719719
running.nextXid=xlrec->nextXid;
720+
running.latestCompletedXid=xlrec->latestCompletedXid;
720721
running.oldestRunningXid=xlrec->oldestRunningXid;
721722
running.xids=xlrec->xids;
722723

@@ -731,8 +732,9 @@ standby_desc_running_xacts(StringInfo buf, xl_running_xacts *xlrec)
731732
{
732733
inti;
733734

734-
appendStringInfo(buf," nextXid %u oldestRunningXid %u",
735+
appendStringInfo(buf," nextXid %ulatestCompletedXid %uoldestRunningXid %u",
735736
xlrec->nextXid,
737+
xlrec->latestCompletedXid,
736738
xlrec->oldestRunningXid);
737739
if (xlrec->xcnt>0)
738740
{
@@ -880,6 +882,7 @@ LogCurrentRunningXacts(RunningTransactions CurrRunningXacts)
880882
xlrec.subxid_overflow=CurrRunningXacts->subxid_overflow;
881883
xlrec.nextXid=CurrRunningXacts->nextXid;
882884
xlrec.oldestRunningXid=CurrRunningXacts->oldestRunningXid;
885+
xlrec.latestCompletedXid=CurrRunningXacts->latestCompletedXid;
883886

884887
/* Header */
885888
rdata[0].data= (char*) (&xlrec);
@@ -902,19 +905,20 @@ LogCurrentRunningXacts(RunningTransactions CurrRunningXacts)
902905

903906
if (CurrRunningXacts->subxid_overflow)
904907
elog(trace_recovery(DEBUG2),
905-
"snapshot of %u running transactions overflowed (lsn %X/%X oldest xid %u next xid %u)",
908+
"snapshot of %u running transactions overflowed (lsn %X/%X oldest xid %ulatest complete %unext xid %u)",
906909
CurrRunningXacts->xcnt,
907910
recptr.xlogid,recptr.xrecoff,
908911
CurrRunningXacts->oldestRunningXid,
912+
CurrRunningXacts->latestCompletedXid,
909913
CurrRunningXacts->nextXid);
910914
else
911915
elog(trace_recovery(DEBUG2),
912-
"snapshot of %u running transaction ids (lsn %X/%X oldest xid %u next xid %u)",
916+
"snapshot of %u running transaction ids (lsn %X/%X oldest xid %ulatest complete %unext xid %u)",
913917
CurrRunningXacts->xcnt,
914918
recptr.xlogid,recptr.xrecoff,
915919
CurrRunningXacts->oldestRunningXid,
920+
CurrRunningXacts->latestCompletedXid,
916921
CurrRunningXacts->nextXid);
917-
918922
}
919923

920924
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp