| From: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
|---|---|
| To: | Melanie Plageman <melanieplageman(at)gmail(dot)com> |
| Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org, Thomas Munro <thomas(dot)munro(at)gmail(dot)com> |
| Subject: | Re: Fix ReadStream handling when heap rescan strategy changes |
| Date: | 2026-11-18 07:47:15 |
| Message-ID: | av1YA7ceBPlflU7Q@bdtpg |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Tue, Nov 17, 2026 at 04:54:08PM -0500, Melanie Plageman wrote:
> On Tue, Nov 3, 2026 at 1:40 AM Bertrand Drouvot
> <bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
> >
> > 0001 takes a different approach (than [2]) and recreates the ReadStream when
> > initscan() changes whether a strategy is active. Ordinary rescans continue to
> > reset and reuse the existing stream. It uses the existing ReadStream APIs, which
> > could also make the backpatches easier.
>
> Now that initscan() has to concern itself with the read stream because
> it has to reset or end the stream before changing the strategy, then
> change the strategy, and then make the new read stream, I think the
> separation between initscan() and making the read stream is no longer
> useful. In fact, the ping-ponging has become confusing. I think your
> version might actually have read_stream_reset() getting called twice
> in some cases since read_stream_end() also calls it. Attached v2 just
> moves all the read stream setup into initscan() and adds some flags to
> make it more clear when we want to rebuild the stream/strategy.
Thanks for looking at it!
Yeah, that makes sense to me. Having initscan() own the reset/end, strategy update,
and stream creation makes the ordering clearer (and also avoids the possible double
reset).
I've one Nit, if we want this comment to describe the complete stream lifecycle,
in heapam.h:
"
stream is allocated at the beginning of the scan and reset on rescan or
when the scan direction changes.
"
worth to change it to something like?
"
The read stream is allocated at the beginning of the scan. It is reset when
the scan direction changes. On rescan, it is reset if strategy use remains
unchanged, and recreated otherwise.
"
Regards,
--
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | David Geier | 2026-11-18 08:06:55 | Re: Use local buffer for packed numerics |
| Previous Message | Chao Li | 2026-11-18 07:46:01 | Fix exclusion of the init fork in table_block_relation_size() |