aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNathan Bossart <nathan@postgresql.org>2024-12-17 15:24:45 -0600
committerNathan Bossart <nathan@postgresql.org>2024-12-17 15:24:45 -0600
commit18452b70acee293d709f475c4551b3b242d4abd1 (patch)
treec328f6ec49224a98e1b6e4c770313086a5e49696
parent3668c1d506bfd061ee6c474502cdbbe3f794a91e (diff)
downloadpostgresql-18452b70acee293d709f475c4551b3b242d4abd1.tar.gz
postgresql-18452b70acee293d709f475c4551b3b242d4abd1.zip
Accommodate very large dshash tables.
If a dshash table grows very large (e.g., the dshash table for cumulative statistics when there are millions of tables), resizing it may fail with an error like: ERROR: invalid DSA memory alloc request size 1073741824 To fix, permit dshash resizing to allocate more than 1 GB by providing the DSA_ALLOC_HUGE flag. Reported-by: Andreas Scherbaum Author: Matthias van de Meent Reviewed-by: Cédric Villemain, Michael Paquier, Andres Freund Discussion: https://postgr.es/m/80a12d59-0d5e-4c54-866c-e69cd6536471%40pgug.de Backpatch-through: 13
-rw-r--r--src/backend/lib/dshash.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/lib/dshash.c b/src/backend/lib/dshash.c
index 93a9e21ddd2..06deb610245 100644
--- a/src/backend/lib/dshash.c
+++ b/src/backend/lib/dshash.c
@@ -887,8 +887,10 @@ 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);
/*