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.96) (envelope-from ) id 1wFusV-005hU9-09 for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 14:18:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wFusT-002DVF-2r for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Apr 2026 14:18:01 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wFusT-002DV6-1P for pgsql-hackers@lists.postgresql.org; Thu, 23 Apr 2026 14:18:01 +0000 Received: from mail.postgrespro.ru ([93.174.132.70]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wFusM-00000002QX5-3KYt for pgsql-hackers@postgresql.org; Thu, 23 Apr 2026 14:17:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1776953871; bh=xnaMwaRTF+OpxNiROfPrxFGG/sVy6odr53s2NG9bDsg=; h=Message-ID:Date:User-Agent:Subject:To:Cc:References:From: In-Reply-To:From; b=yutEhAdX5+k0FtQJKjWE/PcrTL8orK0WDJ55CVhgLIHZz51EFYRjtv84d+iq+kuGV R5+eT3MUHOWfCMiJm1MN5d6lpRH2Q/S5gStfj+A8KZJMWXEMgbWYbqpdQnxUYtxtFK nYTj7G5SaLi9200NWsUW+IJ85J1g9jpaw9QtAokp/vKZ9ovyT7OGvPhJIOzrC189pd ZcVi3wddYVX4eHq5GpJNWK5FS6sF5o/gbF11n7NlkrTAutsvsxxpOh+Wl3z3QjLVYe VjitSjz9EZnFdBdIv1OzqnuwmQonSG47RPboufqb2PSRi4CzIcjvRRXP4O09Q+TUst im3LSM6GtSRBQ== Received: from [10.3.16.29] (broadband-188-255-38-164.ip.moscow.rt.ru [188.255.38.164]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) (Authenticated sender: a.makhmutov@postgrespro.ru) by mail.postgrespro.ru (Postfix/465) with ESMTPSA id 679955FF8A; Thu, 23 Apr 2026 17:17:51 +0300 (MSK) Message-ID: <94e5d94f-c28c-4921-9e03-c76c78d45275@postgrespro.ru> Date: Thu, 23 Apr 2026 17:17:51 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Two issues leading to discrepancies in FSM data on the standby server To: Melanie Plageman , Alexander Korotkov Cc: Andrey Borodin , pgsql-hackers@postgresql.org References: <596c4f1c-f966-4512-b9c9-dd8fbcaf0928@postgrespro.ru> <6A6138F4-8D6F-463D-9ECC-38C0881308FE@yandex-team.ru> <60b79f39-69e5-4c73-a708-6ef1fd5e7980@postgrespro.ru> Content-Language: en-US From: Alexey Makhmutov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 3.0.0.9059, bases: 2026/04/23 07:43:00 #28431106 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 Alexander and Melanie, Thank you very much for the attention to this thread! On 4/22/26 17:15, Melanie Plageman wrote: >>> I don't know how much of Alexey's reported issue was this vs >>> PageGetFreeSpace() in heap_xlog_visible(). The MarkBufferDirty() >>> change is easy to fix, so it probably makes sense to do so. I haven't >>> investigated more about the PageGetFreeSpace() issue. >> Makes sense. I suggest Alexey could clarify this. The issue with 'PageGetFreeSpace' call is completely unrelated to the other issue discussed in this thread (i.e. marking FSM buffer as dirty). In my view it's just a small overlook in the ab7dbd6, which used 'PageGetFreeSpace' instead of 'PageGetHeapFreeSpace'. This latter function calls ‘PageGetFreeSpace’ and additionally checks that there is a space in line pointers section (i.e. checks that MaxHeapTuplesPerPage is not exceeded). If MaxHeapTuplesPerfPage items are already created, then free space for a heap block need to be reported as 0, as no new tuple could be added to the page. Such case could be observed if page has large number of redirect slots created as result of HOT cleanups. Basically, every code working with heap pages should use ‘PageGetHeapFreeSpace’ rather than ‘PageGetFreeSpace’ and function ‘heap_xlog_visible’ is the only place in the code where ‘PageGetFreeSpace’ is used for heap pages. I think that situation with difference between results of these two functions is rarely observed, but it seems to be logical to just call the correct function in all cases. This issue is present in all supported version (PG 14-18), but is not present in current master for PG19 (as ‘heap_xlog_visible’ was removed in a881cc9). > Would be good also if he could add a 19 open item for the > PageGetFreeSpace() thing (in the issues affecting back branches > section) or register a patch for next commitfest (as a bug), so we > don't forget about it. Sure, I could just move this second patch (with test to reproduce the problem) to a different thread and register a new commitfest entry for it. Target version will be 14 (first supported version with the code). As it cannot by applied on top of current master (as the problem was already fixed for PG19 as result of a881cc9), so probably it will be displayed in 'need rebase' status. Thanks, Alexey