agora inbox for [email protected]  
help / color / mirror / Atom feed
[PATCH 7/9] no need for palloc0 here -- simple palloc is enough
140+ messages / 2 participants
[nested] [flat]

* [PATCH 7/9] no need for palloc0 here -- simple palloc is enough
@ 2026-03-12 15:13 Álvaro Herrera <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

From: Álvaro Herrera @ 2026-03-12 15:13 UTC (permalink / raw)

---
 src/backend/replication/pgoutput_repack/pgoutput_repack.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/backend/replication/pgoutput_repack/pgoutput_repack.c b/src/backend/replication/pgoutput_repack/pgoutput_repack.c
index 61cd7c52ae6..73aa6f0589c 100644
--- a/src/backend/replication/pgoutput_repack/pgoutput_repack.c
+++ b/src/backend/replication/pgoutput_repack/pgoutput_repack.c
@@ -197,8 +197,8 @@ store_change(LogicalDecodingContext *ctx, Relation relation,
 		bool	   *isnull;
 
 		desc = RelationGetDescr(relation);
-		attrs = palloc0_array(Datum, desc->natts);
-		isnull = palloc0_array(bool, desc->natts);
+		attrs = palloc_array(Datum, desc->natts);
+		isnull = palloc_array(bool, desc->natts);
 
 		heap_deform_tuple(tuple, desc, attrs, isnull);
 
-- 
2.47.3


--pnppmxqkefjd4hu2
Content-Type: text/plain; charset=utf-8
Content-Disposition: attachment;
	filename*0="0008-XXX-devel-comment-heap_deform_tuple-slot_deform_tupl.noc";
	filename*1="fbot.txt"



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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

* [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic
@ 2026-07-09 18:38 Nathan Bossart <[email protected]>
  0 siblings, 0 replies; 140+ messages in thread

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

---
 src/backend/executor/nodeBitmapHeapscan.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/src/backend/executor/nodeBitmapHeapscan.c b/src/backend/executor/nodeBitmapHeapscan.c
index 83d6478bc2b..f2bb487bf10 100644
--- a/src/backend/executor/nodeBitmapHeapscan.c
+++ b/src/backend/executor/nodeBitmapHeapscan.c
@@ -79,7 +79,6 @@ typedef enum
 /* ----------------
  *	 ParallelBitmapHeapState information
  *		tbmiterator				iterator for scanning current pages
- *		mutex					mutual exclusion for state
  *		state					current state of the TIDBitmap
  *		cv						conditional wait variable
  * ----------------
@@ -87,8 +86,7 @@ typedef enum
 typedef struct ParallelBitmapHeapState
 {
 	dsa_pointer tbmiterator;
-	slock_t		mutex;
-	SharedBitmapState state;
+	pg_atomic_uint32 state;
 	ConditionVariable cv;
 } ParallelBitmapHeapState;
 
@@ -228,9 +226,7 @@ BitmapHeapNext(BitmapHeapScanState *node)
 static inline void
 BitmapDoneInitializingSharedState(ParallelBitmapHeapState *pstate)
 {
-	SpinLockAcquire(&pstate->mutex);
-	pstate->state = BM_FINISHED;
-	SpinLockRelease(&pstate->mutex);
+	pg_atomic_write_membarrier_u32(&pstate->state, BM_FINISHED);
 	ConditionVariableBroadcast(&pstate->cv);
 }
 
@@ -480,11 +476,8 @@ BitmapShouldInitializeSharedState(ParallelBitmapHeapState *pstate)
 
 	while (1)
 	{
-		SpinLockAcquire(&pstate->mutex);
-		state = pstate->state;
-		if (pstate->state == BM_INITIAL)
-			pstate->state = BM_INPROGRESS;
-		SpinLockRelease(&pstate->mutex);
+		state = BM_INITIAL;
+		pg_atomic_compare_exchange_u32(&pstate->state, &state, BM_INPROGRESS);
 
 		/* Exit if bitmap is done, or if we're the leader. */
 		if (state != BM_INPROGRESS)
@@ -538,9 +531,7 @@ ExecBitmapHeapInitializeDSM(BitmapHeapScanState *node,
 
 	pstate->tbmiterator = 0;
 
-	/* Initialize the mutex */
-	SpinLockInit(&pstate->mutex);
-	pstate->state = BM_INITIAL;
+	pg_atomic_init_u32(&pstate->state, BM_INITIAL);
 
 	ConditionVariableInit(&pstate->cv);
 
@@ -565,7 +556,7 @@ ExecBitmapHeapReInitializeDSM(BitmapHeapScanState *node,
 	if (dsa == NULL)
 		return;
 
-	pstate->state = BM_INITIAL;
+	pg_atomic_write_u32(&pstate->state, BM_INITIAL);
 
 	if (DsaPointerIsValid(pstate->tbmiterator))
 		tbm_free_shared_area(dsa, pstate->tbmiterator);
-- 
2.50.1 (Apple Git-155)


--Ot5x3ffkWEuxilWO
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0003-convert-FixedParallelState-last_xlog_end-to-an-at.patch



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


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

Thread overview: 140+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-12 15:13 [PATCH 7/9] no need for palloc0 here -- simple palloc is enough Álvaro Herrera <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state to an atomic Nathan Bossart <[email protected]>
2026-07-09 18:38 [PATCH v1 2/8] convert ParallelBitmapHeapState->state 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