Re: pgsql: Add pg_atomic_unlocked_write_u64

Nathan Bossart <nathandbossart@gmail.com>

From: Nathan Bossart <nathandbossart@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-12-04T15:51:10Z
Lists: pgsql-hackers
On Wed, Dec 03, 2025 at 11:40:47PM +0000, Andres Freund wrote:
> Add pg_atomic_unlocked_write_u64
> 
> The 64bit equivalent of pg_atomic_unlocked_write_u32(), to be used in an
> upcoming patch converting BufferDesc.state into a 64bit atomic.

I noticed that this new function was defined as

	ptr->value = val;

and couldn't figure out why that was safe.  Above
pg_atomic_unlocked_write_u32(), I see this comment:

 * The write is guaranteed to succeed as a whole, i.e. it's not possible to
 * observe a partial write for any reader.  ...

But the new 64-bit version doesn't seem to be surrounded by a check for
PG_HAVE_8BYTE_SINGLE_COPY_ATOMICITY, and I found no discussion about it in
the commit message or the linked thread.  Am I missing something here?

-- 
nathan



Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Improve documentation for pg_atomic_unlocked_write_u32()

  2. Add pg_atomic_unlocked_write_u64