Skip to content

Commit f83040c

Browse files
committed
Fix rare assertion failure in parallel hash join.
When a backend runs out of inner tuples to hash, it should detach from grow_batch_barrier only after it has flushed all batches to disk and merged counters, not before. Otherwise a concurrent backend in ExecParallelHashIncreaseNumBatches() could stop waiting for this backend and try to read tuples before they have been written. This commit reorders those operations and should fix the assertion failures seen occasionally on the build farm since commit 1804284. Author: Thomas Munro Discussion: https://postgr.es/m/E1eRwXy-0004IK-TO%40gemulon.postgresql.org
1 parent be23432 commit f83040c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/backend/executor/nodeHash.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,6 @@ MultiExecParallelHash(HashState *node)
288288
ExecParallelHashTableInsert(hashtable, slot, hashvalue);
289289
hashtable->partialTuples++;
290290
}
291-
BarrierDetach(&pstate->grow_buckets_barrier);
292-
BarrierDetach(&pstate->grow_batches_barrier);
293291

294292
/*
295293
* Make sure that any tuples we wrote to disk are visible to
@@ -304,6 +302,9 @@ MultiExecParallelHash(HashState *node)
304302
*/
305303
ExecParallelHashMergeCounters(hashtable);
306304

305+
BarrierDetach(&pstate->grow_buckets_barrier);
306+
BarrierDetach(&pstate->grow_batches_barrier);
307+
307308
/*
308309
* Wait for everyone to finish building and flushing files and
309310
* counters.

0 commit comments

Comments
 (0)