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

Appearance settings

Commit 481725c

Browse filesBrowse files
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
1 parent a914a04 commit 481725c
Copy full SHA for 481725c

File tree

Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+5
-1
lines changed
Open diff view settings
Collapse file

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

Copy file name to clipboardExpand all lines: src/backend/access/transam/subtrans.c
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
* 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE, and segment numbering at
4545
* 0xFFFFFFFF/SUBTRANS_XACTS_PER_PAGE/SLRU_PAGES_PER_SEGMENT. We need take no
4646
* explicit notice of that fact in this module, except when comparing segment
47-
* and page numbers in TruncateSUBTRANS (see SubTransPagePrecedes).
47+
* and page numbers in TruncateSUBTRANS (see SubTransPagePrecedes) and zeroing
48+
* them in StartupSUBTRANS.
4849
*/
4950

5051
/* We need four bytes per xact */
@@ -254,6 +255,9 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
254255
{
255256
(void) ZeroSUBTRANSPage(startPage);
256257
startPage++;
258+
/* must account for wraparound */
259+
if (startPage > TransactionIdToPage(MaxTransactionId))
260+
startPage=0;
257261
}
258262
(void) ZeroSUBTRANSPage(startPage);
259263

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.