]> granicus.if.org Git - postgresql/commitdiff
Adjust OLDSERXID_MAX_PAGE based on BLCKSZ.
authorRobert Haas <rhaas@postgresql.org>
Thu, 7 Jul 2011 19:05:21 +0000 (15:05 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 7 Jul 2011 19:09:17 +0000 (15:09 -0400)
The value when BLCKSZ = 8192 is unchanged, but with larger-than-normal
block sizes we might need to crank things back a bit, as we'll have
more entries per page than normal in that case.

Kevin Grittner

src/backend/storage/lmgr/predicate.c

index f0c8ee48c340403fdf075b8ee55b44066971845e..7f6dcbb6ca6ec770ae72dec7d25cf411061a8b36 100644 (file)
@@ -305,7 +305,13 @@ static SlruCtlData OldSerXidSlruCtlData;
 #define OLDSERXID_PAGESIZE                     BLCKSZ
 #define OLDSERXID_ENTRYSIZE                    sizeof(SerCommitSeqNo)
 #define OLDSERXID_ENTRIESPERPAGE       (OLDSERXID_PAGESIZE / OLDSERXID_ENTRYSIZE)
-#define OLDSERXID_MAX_PAGE                     (SLRU_PAGES_PER_SEGMENT * 0x10000 - 1)
+
+/*
+ * Set maximum pages based on the lesser of the number needed to track all
+ * transactions and the maximum that SLRU supports.
+ */
+#define OLDSERXID_MAX_PAGE                     Min(SLRU_PAGES_PER_SEGMENT * 0x10000 - 1, \
+                                                                               (MaxTransactionId + 1) / OLDSERXID_ENTRIESPERPAGE - 1)
 
 #define OldSerXidNextPage(page) (((page) >= OLDSERXID_MAX_PAGE) ? 0 : (page) + 1)