From 1f1909855a92be0786d304b8290c9dd4e97a49ba Mon Sep 17 00:00:00 2001 From: Thomas Munro Date: Thu, 7 Jun 2018 11:54:41 +1200 Subject: [PATCH] Respect MaxAllocSize when Parallel Hash increases nbucket. Fix bug #15225 by making sure that we don't exceed MaxAllocSize when increasing the number of buckets. Perhaps later we'll remove that limit and use DSA_ALLOC_HUGE, but for now just prevent further increases like the non-parallel code. Author: Thomas Munro Reported-by: Frits Jalvingh Discussion: https://postgr.es/m/CAKhTGFWcOeOatgjqdYZRr9qfxFQ8vauzdw-42rd%2Bgm2S-PdZUg%40mail.gmail.com --- src/backend/executor/nodeHash.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 4f069d17fd8..e15bc44bca1 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -2820,7 +2820,9 @@ ExecParallelHashTupleAlloc(HashJoinTable hashtable, size_t size, hashtable->batches[0].ntuples = 0; if (hashtable->batches[0].shared->ntuples + 1 > hashtable->nbuckets * NTUP_PER_BUCKET && - hashtable->nbuckets < (INT_MAX / 2)) + hashtable->nbuckets < (INT_MAX / 2) && + hashtable->nbuckets * 2 <= + (MaxAllocSize / sizeof(dsa_pointer_atomic))) { pstate->growth = PHJ_GROWTH_NEED_MORE_BUCKETS; LWLockRelease(&pstate->lock); -- 2.17.0