Don't shut down Gather[Merge] early under Limit.
authorAmit Kapila <[email protected]>
Mon, 18 Nov 2019 08:47:41 +0000 (14:17 +0530)
committerAmit Kapila <[email protected]>
Tue, 26 Nov 2019 03:53:45 +0000 (09:23 +0530)
commitf7ae68aacd9d9cd18a62575b927491d56e57a555
tree891799a417d380a8cf08ac598e9b680c764a227e
parentbd743b6006191796d08d4a1836e539626f01f50d
Don't shut down Gather[Merge] early under Limit.

Revert part of commit 19df1702f5.

Early shutdown was added by that commit so that we could collect
statistics from workers, but unfortunately, it interacted badly with
rescans.  The problem is that we ended up destroying the parallel context
which is required for rescans.  This leads to rescans of a Limit node over
a Gather node to produce unpredictable results as it tries to access
destroyed parallel context.  By reverting the early shutdown code, we
might lose statistics in some cases of Limit over Gather [Merge], but that
will require further study to fix.

Reported-by: Jerry Sievers
Diagnosed-by: Thomas Munro
Author: Amit Kapila, testcase by Vignesh C
Backpatch-through: 9.6
Discussion: https://postgr.es/m/[email protected]
src/backend/executor/nodeLimit.c
src/test/regress/expected/select_parallel.out
src/test/regress/sql/select_parallel.sql