diff options
author | Andres Freund <andres@anarazel.de> | 2018-01-01 14:38:23 -0800 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2018-01-01 14:38:23 -0800 |
commit | 93ea78b17c4743c2b63edb5998fb5796ae57e289 (patch) | |
tree | 45f2cb534f47cd7804e4304e16cf4590392e9314 /src/backend/executor/nodeHash.c | |
parent | 6078770c1a6c247bb74742cb1b82733cce8afcab (diff) | |
download | postgresql-93ea78b17c4743c2b63edb5998fb5796ae57e289.tar.gz postgresql-93ea78b17c4743c2b63edb5998fb5796ae57e289.zip |
Fix EXPLAIN ANALYZE output for Parallel Hash.
In a race case, EXPLAIN ANALYZE could fail to display correct nbatch
and size information. Refactor so that participants report only on
batches they worked on rather than trying to report on all of them,
and teach explain.c to consider the HashInstrumentation object from
all participants instead of picking the first one it can find. This
should fix an occasional build farm failure in the "join" regression
test.
Author: Thomas Munro
Reviewed-By: Andres Freund
Discussion: https://postgr.es/m/30219.1514428346%40sss.pgh.pa.us
Diffstat (limited to 'src/backend/executor/nodeHash.c')
-rw-r--r-- | src/backend/executor/nodeHash.c | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 04eb3650aa3..4e1a2806b55 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -3090,7 +3090,16 @@ ExecHashTableDetachBatch(HashJoinTable hashtable) batch->buckets = InvalidDsaPointer; } } - ExecParallelHashUpdateSpacePeak(hashtable, curbatch); + + /* + * Track the largest batch we've been attached to. Though each + * backend might see a different subset of batches, explain.c will + * scan the results from all backends to find the largest value. + */ + hashtable->spacePeak = + Max(hashtable->spacePeak, + batch->size + sizeof(dsa_pointer_atomic) * hashtable->nbuckets); + /* Remember that we are not attached to a batch. */ hashtable->curbatch = -1; } @@ -3295,19 +3304,3 @@ ExecParallelHashTuplePrealloc(HashJoinTable hashtable, int batchno, size_t size) return true; } - -/* - * Update this backend's copy of hashtable->spacePeak to account for a given - * batch. This is called at the end of hashing for batch 0, and then for each - * batch when it is done or discovered to be already done. The result is used - * for EXPLAIN output. - */ -void -ExecParallelHashUpdateSpacePeak(HashJoinTable hashtable, int batchno) -{ - size_t size; - - size = hashtable->batches[batchno].shared->size; - size += sizeof(dsa_pointer_atomic) * hashtable->nbuckets; - hashtable->spacePeak = Max(hashtable->spacePeak, size); -} |