aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/subtrans.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam/subtrans.c')
-rw-r--r--src/backend/access/transam/subtrans.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c
index 0b774363888..cea778d6a1c 100644
--- a/src/backend/access/transam/subtrans.c
+++ b/src/backend/access/transam/subtrans.c
@@ -22,7 +22,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.8 2005/05/19 21:35:45 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/subtrans.c,v 1.9 2005/06/17 22:32:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -222,22 +222,33 @@ ZeroSUBTRANSPage(int pageno)
/*
* This must be called ONCE during postmaster or standalone-backend startup,
* after StartupXLOG has initialized ShmemVariableCache->nextXid.
+ *
+ * oldestActiveXID is the oldest XID of any prepared transaction, or nextXid
+ * if there are none.
*/
void
-StartupSUBTRANS(void)
+StartupSUBTRANS(TransactionId oldestActiveXID)
{
int startPage;
+ int endPage;
/*
* Since we don't expect pg_subtrans to be valid across crashes, we
- * initialize the currently-active page to zeroes during startup.
+ * initialize the currently-active page(s) to zeroes during startup.
* Whenever we advance into a new page, ExtendSUBTRANS will likewise
* zero the new page without regard to whatever was previously on
* disk.
*/
LWLockAcquire(SubtransControlLock, LW_EXCLUSIVE);
- startPage = TransactionIdToPage(ShmemVariableCache->nextXid);
+ startPage = TransactionIdToPage(oldestActiveXID);
+ endPage = TransactionIdToPage(ShmemVariableCache->nextXid);
+
+ while (startPage != endPage)
+ {
+ (void) ZeroSUBTRANSPage(startPage);
+ startPage++;
+ }
(void) ZeroSUBTRANSPage(startPage);
LWLockRelease(SubtransControlLock);