agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH v29 04/11] Add Incremental View Maintenance support to pg_dump
141+ messages / 2 participants
[nested] [flat]

* [PATCH v29 04/11] Add Incremental View Maintenance support to pg_dump
@ 2020-11-11 08:01 Yugo Nagata <[email protected]>
  0 siblings, 0 replies; 141+ messages in thread

From: Yugo Nagata @ 2020-11-11 08:01 UTC (permalink / raw)

Support CREATE INCREMENTAL MATERIALIZED VIEW syntax.
---
 src/bin/pg_dump/pg_dump.c        | 18 +++++++++++++++---
 src/bin/pg_dump/pg_dump.h        |  1 +
 src/bin/pg_dump/t/002_pg_dump.pl | 15 +++++++++++++++
 3 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index 65f64c282d..013ead7655 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -6354,6 +6354,7 @@ getTables(Archive *fout, int *numTables)
 	int			i_relacl;
 	int			i_acldefault;
 	int			i_ispartition;
+	int			i_isivm;
 
 	/*
 	 * Find all the tables and table-like objects.
@@ -6456,10 +6457,17 @@ getTables(Archive *fout, int *numTables)
 
 	if (fout->remoteVersion >= 100000)
 		appendPQExpBufferStr(query,
-							 "c.relispartition AS ispartition ");
+							 "c.relispartition AS ispartition, ");
 	else
 		appendPQExpBufferStr(query,
-							 "false AS ispartition ");
+							 "false AS ispartition, ");
+
+	if (fout->remoteVersion >= 170000)
+		appendPQExpBufferStr(query,
+							 "c.relisivm AS isivm ");
+	else
+		appendPQExpBufferStr(query,
+							 "false AS isivm ");
 
 	/*
 	 * Left join to pg_depend to pick up dependency info linking sequences to
@@ -6568,6 +6576,7 @@ getTables(Archive *fout, int *numTables)
 	i_relacl = PQfnumber(res, "relacl");
 	i_acldefault = PQfnumber(res, "acldefault");
 	i_ispartition = PQfnumber(res, "ispartition");
+	i_isivm = PQfnumber(res, "isivm");
 
 	if (dopt->lockWaitTimeout)
 	{
@@ -6647,6 +6656,7 @@ getTables(Archive *fout, int *numTables)
 			tblinfo[i].amname = pg_strdup(PQgetvalue(res, i, i_amname));
 		tblinfo[i].is_identity_sequence = (strcmp(PQgetvalue(res, i, i_is_identity_sequence), "t") == 0);
 		tblinfo[i].ispartition = (strcmp(PQgetvalue(res, i, i_ispartition), "t") == 0);
+		tblinfo[i].isivm = (strcmp(PQgetvalue(res, i, i_isivm), "t") == 0);
 
 		/* other fields were zeroed above */
 
@@ -15737,9 +15747,11 @@ dumpTableSchema(Archive *fout, const TableInfo *tbinfo)
 			binary_upgrade_set_pg_class_oids(fout, q,
 											 tbinfo->dobj.catId.oid, false);
 
-		appendPQExpBuffer(q, "CREATE %s%s %s",
+		appendPQExpBuffer(q, "CREATE %s%s%s %s",
 						  tbinfo->relpersistence == RELPERSISTENCE_UNLOGGED ?
 						  "UNLOGGED " : "",
+						  tbinfo->relkind == RELKIND_MATVIEW && tbinfo->isivm ?
+						  "INCREMENTAL " : "",
 						  reltypename,
 						  qualrelname);
 
diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h
index 9036b13f6a..3705891d25 100644
--- a/src/bin/pg_dump/pg_dump.h
+++ b/src/bin/pg_dump/pg_dump.h
@@ -323,6 +323,7 @@ typedef struct _tableInfo
 
 	int			numParents;		/* number of (immediate) parent tables */
 	struct _tableInfo **parents;	/* TableInfos of immediate parents */
+	bool		isivm;			/* is incrementally maintainable materialized view? */
 
 	/*
 	 * These fields are computed only if we decide the table is interesting
diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl
index 0758fe5ea0..fb2f31e191 100644
--- a/src/bin/pg_dump/t/002_pg_dump.pl
+++ b/src/bin/pg_dump/t/002_pg_dump.pl
@@ -2799,6 +2799,21 @@ my %tests = (
 		},
 	},
 
+	'CREATE MATERIALIZED VIEW matview_ivm' => {
+		create_order => 21,
+		create_sql   => 'CREATE INCREMENTAL MATERIALIZED VIEW dump_test.matview_ivm (col1) AS
+					   SELECT col1 FROM dump_test.test_table;',
+		regexp => qr/^
+			\QCREATE INCREMENTAL MATERIALIZED VIEW dump_test.matview_ivm AS\E
+			\n\s+\QSELECT test_table.col1\E
+			\n\s+\QFROM dump_test.test_table\E
+			\n\s+\QWITH NO DATA;\E
+			/xm,
+		like =>
+		  { %full_runs, %dump_test_schema_runs, section_pre_data => 1, },
+		unlike => { exclude_dump_test_schema => 1, },
+	},
+
 	'CREATE POLICY p1 ON test_table' => {
 		create_order => 22,
 		create_sql => 'CREATE POLICY p1 ON dump_test.test_table
-- 
2.25.1


--Multipart=_Mon__28_Aug_2023_11_52_52_+0900_hj6L5h176QaSGtg7
Content-Type: text/x-diff;
 name="v29-0005-Add-Incremental-View-Maintenance-support-to-psql.patch"
Content-Disposition: attachment;
 filename="v29-0005-Add-Incremental-View-Maintenance-support-to-psql.patch"
Content-Transfer-Encoding: 7bit



^ permalink  raw  reply  [nested|flat] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ 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; 141+ 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] 141+ messages in thread


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

Thread overview: 141+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 08:01 [PATCH v29 04/11] Add Incremental View Maintenance support to pg_dump Yugo Nagata <[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]>
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