Re: bug: Gather rescan keeps the first scan's tuple bound in workers

From: Andrei Lepikhov <lepihov(at)gmail(dot)com>
To: shihao zhong <zhong950419(at)gmail(dot)com>, Jeff Davis <pgsql(at)j-davis(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org, Robert Haas <robertmhaas(at)gmail(dot)com>
Subject: Re: bug: Gather rescan keeps the first scan's tuple bound in workers
Date: 2026-11-12 15:45:26
Message-ID: 6d04d232-e1ea-4f7d-a3a9-1ce02a74fd18@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Joao Rito 2026-11-12 16:12:27 Re: Timing issue in pg_basebackup
Previous Message Atisss hh 2026-11-12 15:40:23 Re: BUG #19839: Assert in ReorderBufferRestoreCleanup for aborted, spilled transaction