From 5b8e5e92de0ff68e058b31f450fa55211af7c3a8 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <boekewurm+postgres@gmail.com>
Date: Thu, 12 Dec 2024 22:47:04 +0100
Subject: [PATCH] Fix "invalid DSA memory alloc request size" in pgstat

PGStat may use more than 1GB of DSA segments in its dshash table, so allow the DSHash system to allocate such sizes.
---
 src/backend/lib/dshash.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/backend/lib/dshash.c b/src/backend/lib/dshash.c
index 93a9e21ddd209..c364a38f12d54 100644
--- a/src/backend/lib/dshash.c
+++ b/src/backend/lib/dshash.c
@@ -887,8 +887,9 @@ resize(dshash_table *hash_table, size_t new_size_log2)
 	Assert(new_size_log2 == hash_table->control->size_log2 + 1);
 
 	/* Allocate the space for the new table. */
-	new_buckets_shared = dsa_allocate0(hash_table->area,
-									   sizeof(dsa_pointer) * new_size);
+	new_buckets_shared =
+		dsa_allocate_extended(hash_table->area, sizeof(dsa_pointer) * new_size,
+							  DSA_ALLOC_HUGE | DSA_ALLOC_ZERO);
 	new_buckets = dsa_get_address(hash_table->area, new_buckets_shared);
 
 	/*
