Skip to content

Commit 86a2218

Browse files
committed
Limit Parallel Hash's bucket array to MaxAllocSize.
Make 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. This change avoids the error from bug report #15225. Author: Thomas Munro Reviewed-By: Tom Lane Reported-by: Frits Jalvingh Discussion: https://postgr.es/m/152802081668.26724.16985037679312485972%40wrigleys.postgresql.org
1 parent f6b95ff commit 86a2218

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/backend/executor/nodeHash.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2818,9 +2818,12 @@ ExecParallelHashTupleAlloc(HashJoinTable hashtable, size_t size,
28182818
{
28192819
hashtable->batches[0].shared->ntuples += hashtable->batches[0].ntuples;
28202820
hashtable->batches[0].ntuples = 0;
2821+
/* Guard against integer overflow and alloc size overflow */
28212822
if (hashtable->batches[0].shared->ntuples + 1 >
28222823
hashtable->nbuckets * NTUP_PER_BUCKET &&
2823-
hashtable->nbuckets < (INT_MAX / 2))
2824+
hashtable->nbuckets < (INT_MAX / 2) &&
2825+
hashtable->nbuckets * 2 <=
2826+
MaxAllocSize / sizeof(dsa_pointer_atomic))
28242827
{
28252828
pstate->growth = PHJ_GROWTH_NEED_MORE_BUCKETS;
28262829
LWLockRelease(&pstate->lock);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy