Skip to content

Commit dcd052c

Browse files
committed
Fix pg_atomic_u64 initialization.
As Andres pointed out, pg_atomic_init_u64 must be used to initialize an atomic variable, before it can be accessed with the actual atomic ops. Trying to use pg_atomic_write_u64 on an uninitialized variable leads to a failure with the fallback implementation that uses a spinlock. Discussion: https://www.postgresql.org/message-id/20170816191346.d3ke5tpshhco4bnd%40alap3.anarazel.de
1 parent ec0a69e commit dcd052c

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/backend/access/heap/heapam.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1638,7 +1638,7 @@ heap_parallelscan_initialize(ParallelHeapScanDesc target, Relation relation,
16381638
target->phs_nblocks > NBuffers / 4;
16391639
SpinLockInit(&target->phs_mutex);
16401640
target->phs_startblock = InvalidBlockNumber;
1641-
pg_atomic_write_u64(&target->phs_nallocated, 0);
1641+
pg_atomic_init_u64(&target->phs_nallocated, 0);
16421642
SerializeSnapshot(snapshot, target->phs_snapshot_data);
16431643
}
16441644

0 commit comments

Comments
 (0)