agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Andres Freund <andres@anarazel.de>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: bufmgr: Fix order of operations in UnlockBufHdrExt
Date: Fri, 10 Jul 2026 17:27:09 +0000
Message-ID: <E1wiF0H-000TfH-0E@gemulon.postgresql.org> (raw)

bufmgr: Fix order of operations in UnlockBufHdrExt

In c75ebc657ffc I (Andres) introduced UnlockBufHdrExt() which can set and
clear bits in the buffer state using CAS. Unfortunately I added bits before
subtracting them, which means that a bit that was both removed and set would
remain unset.  Fix the order of operations.

The only known case where that is a problem is that BM_IO_ERROR would not
actually remain set.

It's unfortunately not trivial to add a decent, race-free, test to verify that
BM_IO_ERROR remains set. That's therefore left for the 20 cycle.

Reported-by: Yura Sokolov <y.sokolov@postgrespro.ru>
Discussion: https://postgr.es/m/ab0dcc9e-aba0-44e3-ac23-8d74c48888e6@postgrespro.ru
Backpatch-through: 19, where c75ebc657ffc went in

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/a1b74b7279c24638c44f9d3d1af2da30cfb7068d

Modified Files
--------------
src/include/storage/buf_internals.h | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)



view thread (2+ messages)

Message-ID: <E1wiF0H-000TfH-0E@gemulon.postgresql.org>
Permalink:  ../E1wiF0H-000TfH-0E@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1wiF0H-000TfH-0E@gemulon.postgresql.org

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: andres@anarazel.de, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: bufmgr: Fix order of operations in UnlockBufHdrExt
  In-Reply-To: <E1wiF0H-000TfH-0E@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox