From: Andrei Lepikhov <lepihov@gmail.com>
To: shihao zhong <zhong950419@gmail.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: pgsql-bugs@postgresql.org, Robert Haas <robertmhaas@gmail.com>
Subject: Re: bug: Gather rescan keeps the first scan's tuple bound in workers
Date: Thu, 12 Nov 2026 16:45:26 +0100
Message-ID: <6d04d232-e1ea-4f7d-a3a9-1ce02a74fd18@gmail.com> (raw)
In-Reply-To: <CAGRkXqRGE+TwD0Ttmb4b1J8Vy-drrkZYhh6hOf2_Uz5XKtXsEA@mail.gmail.com>
References: <2701c83e33f3fe66320291fb5d1b74ca2cb90bd7.camel@j-davis.com>
<CAGRkXqRGE+TwD0Ttmb4b1J8Vy-drrkZYhh6hOf2_Uz5XKtXsEA@mail.gmail.com>
On 19/09/2026 05:05, shihao zhong wrote:
> Hi Jeff,
>
> Thanks for reporting this bug.
>
> I can reproduce this on master, and a 1000 row table is enough.
> The attached 0001 adds a tuples_needed argument to
> ExecParallelReinitialize() and stores it in the shared state, the same
> way ExecInitParallelPlan() does. 0002 is a regression test and is
> optional.
>
> For the back branches this changes the signature of an exported
> function. I don't know of any extension that calls it, but if that is
> a concern, a new function could set the bound there instead.
I think you should merge patches 0001 and 0002. While you’re at it, you could
add a couple of words pointing out that the tuples_needed field of the
FixedParallelExecutorState structure needs to be updated on each rescan.
Also, for the back-patch you should add a wrapper for
ExecParallelReinitialize(), so that its existing signature stays intact in the
stable branches.
One more thing: the test covers only Gather Merge. It would be good to add the
same query without ORDER BY in the subquery, so that the plain Gather path is
exercised too.
--
regards, Andrei Lepikhov,
pgEdge
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: lepihov@gmail.com, zhong950419@gmail.com, pgsql@j-davis.com, robertmhaas@gmail.com
Subject: Re: bug: Gather rescan keeps the first scan's tuple bound in workers
In-Reply-To: <6d04d232-e1ea-4f7d-a3a9-1ce02a74fd18@gmail.com>
References: <2701c83e33f3fe66320291fb5d1b74ca2cb90bd7.camel@j-davis.com> <CAGRkXqRGE+TwD0Ttmb4b1J8Vy-drrkZYhh6hOf2_Uz5XKtXsEA@mail.gmail.com> <6d04d232-e1ea-4f7d-a3a9-1ce02a74fd18@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox