agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v3 3/3] Better express platform requirements in s_lock.h.
133+ messages / 1 participants
[nested] [flat]

* [PATCH v3 3/3] Better express platform requirements in s_lock.h.
@ 2026-05-07 20:32  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-05-07 20:32 UTC (permalink / raw)

---
 src/include/storage/s_lock.h | 56 ++++++++++++++++++++----------------
 1 file changed, 32 insertions(+), 24 deletions(-)

diff --git a/src/include/storage/s_lock.h b/src/include/storage/s_lock.h
index fb872edd2f0..c4369ee4ff6 100644
--- a/src/include/storage/s_lock.h
+++ b/src/include/storage/s_lock.h
@@ -44,23 +44,16 @@
  *		atomic test-and-set only when it appears free.
  *
  *	TAS() and TAS_SPIN() are NOT part of the API, and should never be called
- *	directly.
- *
- *	CAUTION: on some platforms TAS() and/or TAS_SPIN() may sometimes report
- *	failure to acquire a lock even when the lock is not locked.  For example,
- *	on Alpha TAS() will "fail" if interrupted.  Therefore a retry loop must
- *	always be used, even if you are certain the lock is free.
+ *	directly.  If a platform-specific TAS() is defined, the platform must
+ *	_not_ define its own S_LOCK().  Conversely, if a platform-specific
+ *	S_LOCK() is defined, the platform must _not_ define its own TAS(), but
+ *	it does need to define its own TAS_SPIN().  Currently, all supported
+ *	platforms define TAS() and use the default S_LOCK() implementation, so
+ *	that is probably a good place to start if adding a new one.
  *
  *	It is the responsibility of these macros to make sure that the compiler
  *	does not re-order accesses to shared memory to precede the actual lock
- *	acquisition, or follow the lock release.  Prior to PostgreSQL 9.5, this
- *	was the caller's responsibility, which meant that callers had to use
- *	volatile-qualified pointers to refer to both the spinlock itself and the
- *	shared data being accessed within the spinlocked critical section.  This
- *	was notationally awkward, easy to forget (and thus error-prone), and
- *	prevented some useful compiler optimizations.  For these reasons, we
- *	now require that the macros themselves prevent compiler re-ordering,
- *	so that the caller doesn't need to take special precautions.
+ *	acquisition, or follow the lock release.
  *
  *	On platforms with weak memory ordering, the TAS(), TAS_SPIN(), and
  *	S_UNLOCK() macros must further include hardware-level memory fence
@@ -72,7 +65,7 @@
  *
  *	On most supported platforms, TAS() uses a tas() function written
  *	in assembly language to execute a hardware atomic-test-and-set
- *	instruction.  Equivalent OS-supplied mutex routines could be used too.
+ *	instruction.  Equivalent compiler intrinsics are another popular option.
  *
  *
  * Portions Copyright (c) 1996-2026, PostgreSQL Global Development Group
@@ -642,20 +635,25 @@ spin_delay(void)
 #endif	/* !defined(TAS) */
 
 
-/* Blow up if we didn't have any way to do spinlocks */
-#ifndef TAS
-#error PostgreSQL does not have spinlock support on this platform.  Please report this to [email protected].
-#endif
-
-
 /*
  * Default Definitions - override these above as needed.
  */
 
-#if !defined(S_LOCK)
+/*
+ * Make sure S_LOCK is defined, either explicitly for the platform or via a TAS
+ * macro for the platform.  Exactly one of either S_LOCK or TAS should be
+ * defined for a supported platform at this point in the file.
+ */
+#if defined(S_LOCK)
+#if defined(TAS)
+#error Both TAS and S_LOCK defined on this platform.  Please report this to [email protected].
+#endif
+#elif defined(TAS)
 #define S_LOCK(lock) \
 	(TAS(lock) ? s_lock((lock), __FILE__, __LINE__, __func__) : 0)
-#endif	 /* S_LOCK */
+#else
+#error Neither TAS nor S_LOCK defined on this platform.  Please report this to [email protected].
+#endif
 
 #if !defined(S_UNLOCK)
 /*
@@ -687,9 +685,19 @@ extern void s_unlock(volatile slock_t *lock);
 #define SPIN_DELAY()	((void) 0)
 #endif	 /* SPIN_DELAY */
 
+/*
+ * We can only define TAS_SPIN if TAS was defined.  Otherwise, the platform
+ * defined its own S_LOCK without TAS, and therefore is responsible for
+ * defining its own TAS_SPIN as well.  (Note that we currently do not have any
+ * platforms that don't define TAS.)
+ */
 #if !defined(TAS_SPIN)
+#if defined(TAS)
 #define TAS_SPIN(lock)	TAS(lock)
-#endif	 /* TAS_SPIN */
+#else
+#error Neither TAS nor TAS_SPIN defined on this platform.  Please report this to [email protected].
+#endif	 /* TAS */
+#endif	 /* ! TAS_SPIN */
 
 
 /*
-- 
2.50.1 (Apple Git-155)


--IHFkEDr8CkxIje3R--





^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread

* [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic
@ 2026-07-09 18:57  Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 133+ messages in thread

From: Nathan Bossart @ 2026-07-09 18:57 UTC (permalink / raw)

---
 src/backend/access/transam/parallel.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/src/backend/access/transam/parallel.c b/src/backend/access/transam/parallel.c
index 89e9d224eec..57f5f26bbec 100644
--- a/src/backend/access/transam/parallel.c
+++ b/src/backend/access/transam/parallel.c
@@ -37,7 +37,6 @@
 #include "storage/ipc.h"
 #include "storage/predicate.h"
 #include "storage/proc.h"
-#include "storage/spin.h"
 #include "tcop/tcopprot.h"
 #include "utils/combocid.h"
 #include "utils/guc.h"
@@ -101,11 +100,8 @@ typedef struct FixedParallelState
 	TimestampTz stmt_ts;
 	SerializableXactHandle serializable_xact_handle;
 
-	/* Mutex protects remaining fields. */
-	slock_t		mutex;
-
 	/* Maximum XactLastRecEnd of any worker. */
-	XLogRecPtr	last_xlog_end;
+	pg_atomic_uint64 last_xlog_end;
 } FixedParallelState;
 
 /*
@@ -358,8 +354,7 @@ InitializeParallelDSM(ParallelContext *pcxt)
 	fps->xact_ts = GetCurrentTransactionStartTimestamp();
 	fps->stmt_ts = GetCurrentStatementStartTimestamp();
 	fps->serializable_xact_handle = ShareSerializableXact();
-	SpinLockInit(&fps->mutex);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_init_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 	shm_toc_insert(pcxt->toc, PARALLEL_KEY_FIXED, fps);
 
 	/* We can skip the rest of this if we're not budgeting for any workers. */
@@ -532,7 +527,7 @@ ReinitializeParallelDSM(ParallelContext *pcxt)
 
 	/* Reset a few bits of fixed parallel state to a clean state. */
 	fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-	fps->last_xlog_end = InvalidXLogRecPtr;
+	pg_atomic_write_u64(&fps->last_xlog_end, InvalidXLogRecPtr);
 
 	/* Recreate error queues (if they exist). */
 	if (pcxt->nworkers > 0)
@@ -900,10 +895,12 @@ WaitForParallelWorkersToFinish(ParallelContext *pcxt)
 	if (pcxt->toc != NULL)
 	{
 		FixedParallelState *fps;
+		XLogRecPtr	last_xlog_end;
 
 		fps = shm_toc_lookup(pcxt->toc, PARALLEL_KEY_FIXED, false);
-		if (fps->last_xlog_end > XactLastRecEnd)
-			XactLastRecEnd = fps->last_xlog_end;
+		last_xlog_end = pg_atomic_read_u64(&fps->last_xlog_end);
+		if (last_xlog_end > XactLastRecEnd)
+			XactLastRecEnd = last_xlog_end;
 	}
 }
 
@@ -1596,10 +1593,7 @@ ParallelWorkerReportLastRecEnd(XLogRecPtr last_xlog_end)
 	FixedParallelState *fps = MyFixedParallelState;
 
 	Assert(fps != NULL);
-	SpinLockAcquire(&fps->mutex);
-	if (fps->last_xlog_end < last_xlog_end)
-		fps->last_xlog_end = last_xlog_end;
-	SpinLockRelease(&fps->mutex);
+	pg_atomic_monotonic_advance_u64(&fps->last_xlog_end, last_xlog_end);
 }
 
 /*
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-convert-PROC_HDR-startupBufferPinWaitBufId-to-an-.patch



^ permalink  raw  reply  [nested|flat] 133+ messages in thread


end of thread, other threads:[~2026-07-09 18:57 UTC | newest]

Thread overview: 133+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-05-07 20:32 [PATCH v3 3/3] Better express platform requirements in s_lock.h. Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:57 [PATCH v1 3/8] convert FixedParallelState->last_xlog_end to an atomic Nathan Bossart <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox