| From: | Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
| Cc: | Melanie Plageman <melanieplageman(at)gmail(dot)com>, 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 12:15:45 |
| Message-ID: | CAN55FZ0e9o6d1MkH5HEjp+yiiJaocb=E2Sk3EGAeSbYGwakaTQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
On Wed, 18 Nov 2026 at 10:47, Bertrand Drouvot
<bertranddrouvot(dot)pg(at)gmail(dot)com> wrote:
>
> 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).
+1, v2 LGTM.
> "
> 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.
> "
I think this is a nice improvement. This comment needs update after
this patch and I think what you recommended is correct and clear.
--
Regards,
Nazir Bilal Yavuz
Microsoft
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Greg Burd | 2026-11-18 11:47:51 | Re: Hash index: stop registering pin-only bucket pages in WAL (remove REGBUF_NO_CHANGE) |