BM_IO_ERROR flag is lost in TerminateBufferIO due to order of operations in UnlockBufHdrExt

From: Yura Sokolov <y(dot)sokolov(at)postgrespro(dot)ru>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>
Subject: BM_IO_ERROR flag is lost in TerminateBufferIO due to order of operations in UnlockBufHdrExt
Date: 2026-03-25 14:51:30
Message-ID: ab0dcc9e-aba0-44e3-ac23-8d74c48888e6@postgrespro.ru
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Good day, Andres and hackers.

UnlockBufHdrExt does:

buf_state |= set_bits;
buf_state &= ~unset_bits;
buf_state &= ~BM_LOCKED;

TerminateBufferIO unconditionally does:

unset_flag_bits |= BM_IO_ERROR;

Due to this, AbortBufferIO and buffer_readv_complete_one are failed
to set BM_IO_ERROR with call to TerminateBufferIO.

It was found with proprietary code that was triggered on
PGAIO_RS_ERROR and made assertion on BM_IO_ERROR presence.

--
regards
Yura Sokolov aka funny-falcon

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2026-03-25 15:15:18 Re: Don't synchronously wait for already-in-progress IO in read stream
Previous Message Alexandre Felipe 2026-03-25 14:47:58 Re: SLOPE - Planner optimizations on monotonic expressions.