public inbox for [email protected]
help / color / mirror / Atom feedFrom: Matthias van de Meent <[email protected]>
To: Andreas 'ads' Scherbaum <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Crash: invalid DSA memory alloc request
Date: Thu, 12 Dec 2024 22:49:35 +0100
Message-ID: <CAEze2WhO235HKnc=qCh7GmjXBpL9LDPC6qQk4pvq57cZiDC7Pg@mail.gmail.com> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
On Thu, 12 Dec 2024 at 22:28, Andreas 'ads' Scherbaum <[email protected]> wrote:
>
>
> Hello,
>
> I'm running a couple of large tests, and in this particular test I have
> a few million tables more.
>
> At some point it fails, and I gathered the following trace:
>
>
> 2024-12-12 22:22:55.307 CET [1496210] ERROR: invalid DSA memory alloc
> request size 1073741824
> 2024-12-12 22:22:55.307 CET [1496210] BACKTRACE:
> postgres: ads tabletest [local] CREATE TABLE(+0x15e570)
> [0x6309c379c570]
> postgres: ads tabletest [local] CREATE
> TABLE(dshash_find_or_insert+0x1a4) [0x6309c39882d4]
> postgres: ads tabletest [local] CREATE
> TABLE(pgstat_get_entry_ref+0x440) [0x6309c3b0a530]
It looks like the dshash table used in the pgstats system uses
resize(), which only specifies DSA_ALLOC_ZERO, not DSA_ALLOC_HUGE,
causing issues when the table grows larger than 1 GB.
I expect that error to disappear when you replace the
dsa_allocate0(...) call in dshash.c's resize function with
dsa_allocate_extended(..., DSA_ALLOC_HUGE | DSA_ALLOC_ZERO) as
attached, but haven't tested it due to a lack of database with
millions of relations.
Kind regards,
Matthias van de Meent
Attachments:
[application/octet-stream] dshash_pgstat_fix.patch (1.1K, ../CAEze2WhO235HKnc=qCh7GmjXBpL9LDPC6qQk4pvq57cZiDC7Pg@mail.gmail.com/2-dshash_pgstat_fix.patch)
download | inline diff:
From 5b8e5e92de0ff68e058b31f450fa55211af7c3a8 Mon Sep 17 00:00:00 2001
From: Matthias van de Meent <[email protected]>
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);
/*
view thread (7+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected]
Subject: Re: Crash: invalid DSA memory alloc request
In-Reply-To: <CAEze2WhO235HKnc=qCh7GmjXBpL9LDPC6qQk4pvq57cZiDC7Pg@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox