0001-Fix-setting-next-multixid-s-offset-at-offset-wraparo.patch

text/x-patch

Filename: 0001-Fix-setting-next-multixid-s-offset-at-offset-wraparo.patch
Type: text/x-patch
Part: 0
Message: Re: IPC/MultixactCreation on the Standby server

Patch

Same data as JSON: GET /api/v1/attachments/:id/patch the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes. API reference →
Format: format-patch
Series: patch 0001
Subject: Fix setting next multixid's offset at offset wraparound
File+
src/backend/access/transam/multixact.c 7 2
From f9b2cc8daea1cd0462e9455736237da0f7f00a3d Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Thu, 4 Dec 2025 16:05:13 +0200
Subject: [PATCH 1/1] Fix setting next multixid's offset at offset wraparound

---
 src/backend/access/transam/multixact.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/backend/access/transam/multixact.c b/src/backend/access/transam/multixact.c
index 27f02faec80..8ed3fd9d071 100644
--- a/src/backend/access/transam/multixact.c
+++ b/src/backend/access/transam/multixact.c
@@ -909,6 +909,7 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 	int64		next_pageno;
 	int			next_entryno;
 	MultiXactOffset *next_offptr;
+	MultiXactOffset next_offset;
 	LWLock	   *lock;
 	LWLock	   *prevlock = NULL;
 
@@ -976,11 +977,15 @@ RecordNewMultiXact(MultiXactId multi, MultiXactOffset offset,
 		next_offptr += next_entryno;
 	}
 
-	if (*next_offptr != offset + nmembers)
+	/* Like in GetNewMultiXactId(), skip over offset 0 */
+	next_offset = offset + nmembers;
+	if (next_offset == 0)
+		next_offset = 1;
+	if (*next_offptr != next_offset)
 	{
 		/* should already be set to the correct value, or not at all */
 		Assert(*next_offptr == 0);
-		*next_offptr = offset + nmembers;
+		*next_offptr = next_offset;
 		MultiXactOffsetCtl->shared->page_dirty[slotno] = true;
 	}
 
-- 
2.47.3