Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tM6ZU-001mjJ-W4 for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Dec 2024 14:23:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tM6ZS-007LVY-Iu for pgsql-hackers@arkaria.postgresql.org; Fri, 13 Dec 2024 14:23:11 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tM6ZS-007LVQ-7R for pgsql-hackers@lists.postgresql.org; Fri, 13 Dec 2024 14:23:11 +0000 Received: from mailfr00.databene.net ([31.170.12.19]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tM6ZQ-002ejZ-18 for pgsql-hackers@lists.postgresql.org; Fri, 13 Dec 2024 14:23:10 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by mailfr00.databene.net (Postfix) with ESMTP id 34AFB5F2CC; Fri, 13 Dec 2024 15:23:07 +0100 (CET) X-Virus-Scanned: by Amavis at mailfr00.databene.net Received: from mailfr00.databene.net ([127.0.0.1]) by localhost (databene-mailfr00.evolix.net [127.0.0.1]) (amavis, port 10024) with LMTP id Ae10MWScOVp7; Fri, 13 Dec 2024 15:23:04 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=data-bene.io; s=2024; t=1734099784; bh=/pxd3Ug3+hKxQDPNiGQDFdYcU0XUmg45kSZZ3XF1jxE=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=O/dwTkBm9lJwzu5arx363IqE4Qy6QcAJ4OsUgusp35/BhlaEIVW+jKmEQbJib+Wgh yZH2FWV8LdKvyFKHKv9TjPppYcQ3JJ68AUNumMKe7ZhQ/mROJdovA8JVsO/ZAquplF zDR6o2WwhA9HtpX9iIGCxT+/2RAistATnovhrnLeLJydbuwqec5A6r2V7TgNVgkm5E PpxRgnAL3GB0gmfluKjxMF4zcNi84F/e9tdTLk/0zohSRnxRfcl6j+pITy3lckwjF4 FTk5C/f+kubYqTVNEdn03HuRX0j0FR0h08vfMClgsrHQeJij3sVLKHzmpc5GC/6Vmu Gp7FXpb+psCHXQlI54aQuAXKEhPF5gFhd9q7xrKwqxmAa9ja13wDWouOMvHLtkArnK 3/QhfyvWtSJxwx6ytTlH2VyoBj8VjP2yDAeqMwA4w+c3/Jhc9lrg2XGlMyciax/Q7b w/UsV32yN4FQPVxLGM0zkkwPsmaUTuXf1f+WXIZlr/I6VKQq9bXpKweVyHpY2GpNpe eStkz3jWY/v+SCObwCeNvdO35hU+rw5mCK1YfoZj1bC9NzUKySPr9btnoXcXqbC0kQ TU2NJYQQR/aM78UCJn+lAnvGFcTZbI5plArwLSWOjzANZGR3TAbRd9YYcnWTUJ/kL3 mQSbf9xn29ry7FLEjoYunn9o= Received: from [192.168.10.107] (257400053.box.freepro.com [95.178.90.96]) by mailfr00.databene.net (Postfix) with ESMTPSA id 13B6C5F293; Fri, 13 Dec 2024 15:23:04 +0100 (CET) Message-ID: <5a1bf74c-99f7-4e21-9aa2-7ae0dfe1dde0@Data-Bene.io> Date: Fri, 13 Dec 2024 15:23:02 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Crash: invalid DSA memory alloc request To: Matthias van de Meent , Andreas 'ads' Scherbaum Cc: PostgreSQL Hackers References: <80a12d59-0d5e-4c54-866c-e69cd6536471@pgug.de> Content-Language: en-US From: =?UTF-8?Q?C=C3=A9dric_Villemain?= Organization: Data Bene In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/12/2024 22:49, Matthias van de Meent wrote: > On Thu, 12 Dec 2024 at 22:28, Andreas 'ads' Scherbaum 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. IIUC the table is doubled in size when filled over 75%, so we went from 500MB to 1GB here, doubling the number of available buckets. It's probably good up to a point but the size limit is exceed here only by 1 byte and 1GB-1 are hopefully more than enough pointers. Is it interesting to revisit the logic to increase size less quickly (over 500MB) ? (if at all possible given how buckets and partitions are managed). There is this comment in 8c0d7bafad3 which introduce this "dshash": There is a wide range of potential users for such a hash table, though it's very likely the interface will need to evolve as we come to understand the needs of different kinds of users. E.g support for iterators and incremental resizing is planned for later commits and the details of the callback signatures are likely to change. I'm unsure iterators and incremental resizing has made it ? --- Cédric Villemain +33 6 20 30 22 52 https://www.Data-Bene.io PostgreSQL Support, Expertise, Training, R&D