Commit 481725c0 authored by Simon Riggs's avatar Simon Riggs

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
parent a914a041
...@@ -44,7 +44,8 @@ ...@@ -44,7 +44,8 @@
* 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE, and segment numbering at * 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE, and segment numbering at
* 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no * 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 * 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 */ /* We need four bytes per xact */
...@@ -254,6 +255,9 @@ StartupSUBTRANS(TransactionId oldestActiveXID) ...@@ -254,6 +255,9 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
{ {
(void) ZeroSUBTRANSPage(startPage); (void) ZeroSUBTRANSPage(startPage);
startPage++; startPage++;
/* must account for wraparound */
if (startPage > TransactionIdToPage(MaxTransactionId))
startPage=0;
} }
(void) ZeroSUBTRANSPage(startPage); (void) ZeroSUBTRANSPage(startPage);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment