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 1tn0rA-0016J6-R2 for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Feb 2025 19:44:41 +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 1tn0r8-007ddf-If for pgsql-hackers@arkaria.postgresql.org; Tue, 25 Feb 2025 19:44:38 +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 1tn0r8-007ddX-8F for pgsql-hackers@lists.postgresql.org; Tue, 25 Feb 2025 19:44:38 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1tn0r4-0004Al-1F for pgsql-hackers@lists.postgresql.org; Tue, 25 Feb 2025 19:44:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1740512673; bh=dJ4VyVFiSStDuZox/2Uk1FDh0BdnleWQ5zTe1tVVSLg=; h=Date:From:To:Subject:Message-ID:From; b=E8UW3MgUB6tpzZ5iCLuyMZpVpaWnB9CfXFpFh2H+5DsASeIc8LZf4TcC8PZ42lsPf AhzGx9wOe5e3T1214r7tYncq1MbtqWsueLaVFxyoppc2jtcXKYZ7BH06plTgA8lO3f NPSpLiE2yi4fCuYdiw9VAx/aiz4FploMrRsUkAhv6du5kOdKqwKs6DxC39apI2GcK0 mtPRZrVzOeyNo/RK7jVgDzvCTUm4fgyDQC7+q9uNk2zVQ9ChGzoZnRqfZzCgLWIDmq bgB6u/RhwxPH7nxy39xB+ft6t3cUM4+Bq0Pc79lnJIk//sffai+oHmYpHGtXPoySMz PvaJRecfqC43w== Received: from mail.postgrespro.ru (webmail-master-mstn.l.postgrespro.ru [192.168.2.26]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: e.sokolova@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id D51EB5FF54 for ; Tue, 25 Feb 2025 22:44:33 +0300 (MSK) MIME-Version: 1.0 Date: Tue, 25 Feb 2025 22:44:33 +0300 From: Ekaterina Sokolova To: pgsql-hackers@lists.postgresql.org Subject: Proposal: Limitations of palloc inside checkpointer Message-ID: X-Sender: e.sokolova@postgrespro.ru Organization: Postgres Professional Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-KSMG-AntiPhishing: NotDetected, bases: 2025/02/25 18:41:00 X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/02/25 18:19:00 #27457483 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: not scanned, disabled by settings X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, hackers! Historically, the checkpointer process use palloc() into AbsorbSyncRequests() function. Therefore, the checkpointer does not expect to receive a request larger than 1 GB. We encountered a case where the database went into recovery state, after applying all wal, the checkpointer process generated an "invalid memory alloc request size" error and entered a loop. But it is quite acceptable for the recovery state to receive such a large allocation request. A simple solution to this problem is to use palloc_extended() instead of palloc(). But is it safe to allow the checkpointer to allocate so much memory at once? I have proposal to update this memory allocation but I need your ideas and advices on how to do it in appropriate way. As an idea, we can replace the array with a list of arrays to allocate memory in chunks. As a bad idea, we can process a temporary array without locking. I would be glad to hear your ideas and suggestions about this topic. Have a nice day! -- Ekaterina Sokolova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company