aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2021-10-18 20:42:10 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2021-10-18 20:42:10 +0300
commitfc0f3b4cb0e882a9c5d51c302d4aa3591e4f80fd (patch)
treeb7ff7cd292094a019d0fd9f8d995902eea2527e2
parentaa3ac6453b28049b3198433b75228271b7612d4a (diff)
downloadpostgresql-fc0f3b4cb0e882a9c5d51c302d4aa3591e4f80fd.tar.gz
postgresql-fc0f3b4cb0e882a9c5d51c302d4aa3591e4f80fd.zip
Fix parallel sort, broken by the balanced merge patch.
The code for initializing the tapes on each merge iteration was skipped in a parallel worker. I put the !WORKER(state) check in wrong place while rebasing the patch. That caused failures in the index build in 'multiple-row-versions' isolation test, in multiple buildfarm members. On my laptop it was easier to reproduce by building an index on a larger table, so that you got a parallel sort more reliably.
-rw-r--r--src/backend/utils/sort/tuplesort.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c
index 0c5c574cbd3..9e93908c657 100644
--- a/src/backend/utils/sort/tuplesort.c
+++ b/src/backend/utils/sort/tuplesort.c
@@ -2923,7 +2923,7 @@ mergeruns(Tuplesortstate *state)
* Rewind all the output tapes, and make them inputs for the next
* pass.
*/
- if (state->nInputRuns == 0 && !WORKER(state))
+ if (state->nInputRuns == 0)
{
int64 input_buffer_size;
@@ -2975,7 +2975,8 @@ mergeruns(Tuplesortstate *state)
* sorted tape, we can stop at this point and do the final merge
* on-the-fly.
*/
- if (!state->randomAccess && state->nInputRuns <= state->nInputTapes)
+ if (!state->randomAccess && state->nInputRuns <= state->nInputTapes
+ && !WORKER(state))
{
/* Tell logtape.c we won't be writing anymore */
LogicalTapeSetForgetFreeSpace(state->tapeset);