diff options
author | Simon Riggs <simon@2ndQuadrant.com> | 2016-02-19 08:31:39 +0000 |
---|---|---|
committer | Simon Riggs <simon@2ndQuadrant.com> | 2016-02-19 08:31:39 +0000 |
commit | c479024d325a02e0eb352e5b7f1873b4c51a5205 (patch) | |
tree | 0166bbdda10b2edaedf26e3be565a54517e2f44b | |
parent | 6f43c4d34844c400a159c40909ff227ca1d870cc (diff) | |
download | postgresql-c479024d325a02e0eb352e5b7f1873b4c51a5205.tar.gz postgresql-c479024d325a02e0eb352e5b7f1873b4c51a5205.zip |
Correct StartupSUBTRANS for page wraparound
StartupSUBTRANS() incorrectly handled cases near the max pageid in the subtrans
data structure, which in some cases could lead to errors in startup for Hot
Standby.
This patch wraps the pageids correctly, avoiding any such errors.
Identified by exhaustive crash testing by Jeff Janes.
Jeff Janes
-rw-r--r-- | src/backend/access/transam/subtrans.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/backend/access/transam/subtrans.c b/src/backend/access/transam/subtrans.c index 6b709823227..dde72b7d2e1 100644 --- a/src/backend/access/transam/subtrans.c +++ b/src/backend/access/transam/subtrans.c @@ -44,7 +44,8 @@ * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE, and segment numbering at * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no * explicit notice of that fact in this module, except when comparing segment - * and page numbers in TruncateSUBTRANS (see SubTransPagePrecedes). + * and page numbers in TruncateSUBTRANS (see SubTransPagePrecedes) and zeroing + * them in StartupSUBTRANS. */ /* We need four bytes per xact */ @@ -253,6 +254,9 @@ StartupSUBTRANS(TransactionId oldestActiveXID) { (void) ZeroSUBTRANSPage(startPage); startPage++; + /* must account for wraparound */ + if (startPage > TransactionIdToPage(MaxTransactionId)) + startPage=0; } (void) ZeroSUBTRANSPage(startPage); |