agora inbox for pgsql-committers@postgresql.org  
help / color / mirror / Atom feed
From: Peter Geoghegan <pg@bowt.ie>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Have read_stream_reset reset pending_read_nblocks.
Date: Tue, 15 Sep 2026 18:37:28 +0000
Message-ID: <E1x6Y24-00000000Tek-1lWO@gemulon.postgresql.org> (raw)

Have read_stream_reset reset pending_read_nblocks.

Otherwise, a read of blocks the stream is about to throw away can be
started and then waited for.  read_stream_reset drains the stream by
calling read_stream_next_buffer, whose look-ahead treats the zeroed
distance as end of stream, leading to it spuriously performing the
pending read.  This caused a pathological regression for a nested loop
antijoin query when run with the upcoming index prefetching patch series
applied.

This bug affects all stable branches with the read stream, which was
added to Postgres 17 by commit b5a9b18cd0b.  No backpatch for now,
though, since without index prefetching the added overhead for realistic
query plans is negligible.

Author: Tomas Vondra <tomas@vondra.me>
Discussion: https://postgr.es/m/CAH2-WzkKY8b42sZSPWJceT5Fn_THk3ZgcaM8ch3Hzw+XvhP0zQ@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/862092932c9479b79732f3b441da05453ea5e06d

Modified Files
--------------
src/backend/storage/aio/read_stream.c | 3 +++
1 file changed, 3 insertions(+)



Message-ID: <E1x6Y24-00000000Tek-1lWO@gemulon.postgresql.org>
Permalink:  ../E1x6Y24-00000000Tek-1lWO@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1x6Y24-00000000Tek-1lWO@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: pg@bowt.ie, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Have read_stream_reset reset pending_read_nblocks.
  In-Reply-To: <E1x6Y24-00000000Tek-1lWO@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