mirror of
https://github.com/postgres/postgres.git
synced 2025-07-05 07:21:24 +03:00
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
This commit is contained in:
@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user