v8-0003-refactor-predicate.c-inline-SerialInit-to-the-cal.patch
text/x-patch
Filename: v8-0003-refactor-predicate.c-inline-SerialInit-to-the-cal.patch
Type: text/x-patch
Part: 2
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 v8-0003
Subject: refactor predicate.c: inline SerialInit to the caller
| File | + | − |
|---|---|---|
| src/backend/storage/lmgr/predicate.c | 29 | 44 |
From 110197f7e862ee7fd88573c968d4881e1fa3f111 Mon Sep 17 00:00:00 2001
From: Heikki Linnakangas <heikki.linnakangas@iki.fi>
Date: Thu, 19 Mar 2026 17:21:30 +0200
Subject: [PATCH v8 03/16] refactor predicate.c: inline SerialInit to the
caller
The ShmemInit function is very complicated currently. These
refactorings move it in a direction that is more natural with the new
shmem callbacks.
---
src/backend/storage/lmgr/predicate.c | 73 +++++++++++-----------------
1 file changed, 29 insertions(+), 44 deletions(-)
diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c
index edabbf4ca31..27682f416e7 100644
--- a/src/backend/storage/lmgr/predicate.c
+++ b/src/backend/storage/lmgr/predicate.c
@@ -444,7 +444,6 @@ static void FlagSxactUnsafe(SERIALIZABLEXACT *sxact);
static bool SerialPagePrecedesLogically(int64 page1, int64 page2);
static int serial_errdetail_for_io_error(const void *opaque_data);
-static void SerialInit(void);
static void SerialAdd(TransactionId xid, SerCommitSeqNo minConflictCommitSeqNo);
static SerCommitSeqNo SerialGetMinConflictCommitSeqNo(TransactionId xid);
static void SerialSetActiveSerXmin(TransactionId xid);
@@ -809,48 +808,6 @@ SerialPagePrecedesLogicallyUnitTests(void)
}
#endif
-/*
- * Initialize for the tracking of old serializable committed xids.
- */
-static void
-SerialInit(void)
-{
- bool found;
-
- /*
- * Set up SLRU management of the pg_serial data.
- */
- SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
- SerialSlruCtl->errdetail_for_io_error = serial_errdetail_for_io_error;
- SimpleLruInit(SerialSlruCtl, "serializable",
- serializable_buffers, 0, "pg_serial",
- LWTRANCHE_SERIAL_BUFFER, LWTRANCHE_SERIAL_SLRU,
- SYNC_HANDLER_NONE, false);
-#ifdef USE_ASSERT_CHECKING
- SerialPagePrecedesLogicallyUnitTests();
-#endif
- SlruPagePrecedesUnitTests(SerialSlruCtl, SERIAL_ENTRIESPERPAGE);
-
- /*
- * Create or attach to the SerialControl structure.
- */
- serialControl = (SerialControl)
- ShmemInitStruct("SerialControlData", sizeof(SerialControlData), &found);
-
- Assert(found == IsUnderPostmaster);
- if (!found)
- {
- /*
- * Set control information to reflect empty SLRU.
- */
- LWLockAcquire(SerialControlLock, LW_EXCLUSIVE);
- serialControl->headPage = -1;
- serialControl->headXid = InvalidTransactionId;
- serialControl->tailXid = InvalidTransactionId;
- LWLockRelease(SerialControlLock);
- }
-}
-
/*
* GUC check_hook for serializable_buffers
*/
@@ -1358,7 +1315,35 @@ PredicateLockShmemInit(void)
* Initialize the SLRU storage for old committed serializable
* transactions.
*/
- SerialInit();
+ SerialSlruCtl->PagePrecedes = SerialPagePrecedesLogically;
+ SerialSlruCtl->errdetail_for_io_error = serial_errdetail_for_io_error;
+ SimpleLruInit(SerialSlruCtl, "serializable",
+ serializable_buffers, 0, "pg_serial",
+ LWTRANCHE_SERIAL_BUFFER, LWTRANCHE_SERIAL_SLRU,
+ SYNC_HANDLER_NONE, false);
+#ifdef USE_ASSERT_CHECKING
+ SerialPagePrecedesLogicallyUnitTests();
+#endif
+ SlruPagePrecedesUnitTests(SerialSlruCtl, SERIAL_ENTRIESPERPAGE);
+
+ /*
+ * Create or attach to the SerialControl structure.
+ */
+ serialControl = (SerialControl)
+ ShmemInitStruct("SerialControlData", sizeof(SerialControlData), &found);
+
+ Assert(found == IsUnderPostmaster);
+ if (!found)
+ {
+ /*
+ * Set control information to reflect empty SLRU.
+ */
+ LWLockAcquire(SerialControlLock, LW_EXCLUSIVE);
+ serialControl->headPage = -1;
+ serialControl->headXid = InvalidTransactionId;
+ serialControl->tailXid = InvalidTransactionId;
+ LWLockRelease(SerialControlLock);
+ }
}
/*
--
2.47.3