pgsql: Convert SharedFileSet->refcnt to an atomic variable.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Convert SharedFileSet->refcnt to an atomic variable.
Date: 2026-09-22 19:23:32
Message-ID: E1x965U-00000000oQm-3Z3Q@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Convert SharedFileSet->refcnt to an atomic variable.

Currently, this variable is an int protected by a spinlock. By
converting it to an atomic variable, we can remove the spinlock.
Detaching becomes an atomic subtract, and attaching becomes a
compare-and-exchange loop, since it must not resurrect a fileset
whose reference count has already reached zero.

Reviewed-by: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Tested-by: solai v <solai(dot)cdac(at)gmail(dot)com>
Discussion: https://postgr.es/m/alAJeRRzehDjLaF1%40nathan

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/09a579abaca86bcd85ebc49b247d2ec58bdc6d3b

Modified Files
--------------
src/backend/storage/file/sharedfileset.c | 33 ++++++++++++++------------------
src/include/storage/sharedfileset.h | 5 ++---
2 files changed, 16 insertions(+), 22 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message noreply 2026-09-22 20:40:27 pgsql: Tag refs/tags/REL_19_BETA4 was created
Previous Message Nathan Bossart 2026-09-22 18:51:19 pgsql: Convert Sharedsort's worker counters to atomic variables.