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 1vgSli-00DO9j-12 for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 19:12:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vgSlh-000Y7M-1O for pgsql-hackers@arkaria.postgresql.org; Thu, 15 Jan 2026 19:12:29 +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 1vgSlJ-000VWB-1E for pgsql-hackers@lists.postgresql.org; Thu, 15 Jan 2026 19:12:05 +0000 Received: from meesny.iki.fi ([195.140.195.201]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vgSlC-000cGa-1B for pgsql-hackers@postgresql.org; Thu, 15 Jan 2026 19:12:04 +0000 Received: from [10.0.2.15] (unknown [130.41.208.2]) (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) (No client certificate requested) (Authenticated sender: hlinnaka) by meesny.iki.fi (Postfix) with ESMTPSA id 4dsXfM5lffzyTj; Thu, 15 Jan 2026 21:11:55 +0200 (EET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1768504316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WR9GOwwSmReu+p3NN5IyCqXa3XpZ1SPXfRJIPnpvtQA=; b=gj37ydF5X4l95Skrm6fl5NG44ZWBFcXFUDziCOxgEOHeNzBC47gapGQA9hoSDI/6C66ATz Nu3sM8ueUnuQ7xUsZfulUxK1LcdXhgqLPDBHni5bs4ysLwQU8o4W1LfkMZbx3Tt1oC8J2v a7ktm5w/zG528GRV2frqeUCflpVy0hk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=meesny; t=1768504316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WR9GOwwSmReu+p3NN5IyCqXa3XpZ1SPXfRJIPnpvtQA=; b=WBgsf18iv0lTN2QDTHK8D9Eod1AlnOvrqIe0vkkVxWtGYsjSs8PZAYk/szqgpc+vzki4GI dRRUw54NvTOz+sYEteCLNRPqek4K6uJ8j3kI9eU7sxF1OtJEagxSqYwWFk3bEbZ8saCJnJ MCPe+owha3ZeSCPG7S96rPjP3kzr1XQ= ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi ARC-Seal: i=1; a=rsa-sha256; d=iki.fi; s=meesny; cv=none; t=1768504316; b=VJHVM7tKYj9snJuLRymJEIONGyBm63585IYlx0riLo+mnpMccA0NXYjBCi3wi87N4I2btr YmEnOwRPEwBAATrYJjCnuycbkYqDLWSAw/pwocBNYolWb/tAAKl3kEbLV3Bkp8yEHNNCVW 0rkcHkmCC3CG7Us0O/GSD2AdwQOfdpM= Message-ID: <7e5af8a3-45fe-4c37-9f66-e8bde6c5012b@iki.fi> Date: Thu, 15 Jan 2026 21:11:54 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Fix possible 'unexpected data beyond EOF' on replica restart To: Anthonin Bonnefoy Cc: Amul Sul , PostgreSQL Hackers References: <02e720a8-761b-4309-b26f-f41c288f7990@iki.fi> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 12/01/2026 10:34, Anthonin Bonnefoy wrote: > Here's a new version with a bit of rewording. Applied to all branches. Thanks! I left out this comment change on smgrtruncate(): > @@ -870,6 +870,9 @@ smgrnblocks_cached(SMgrRelation reln, ForkNumber forknum) > * be called in a critical section, but the current size must be checked > * outside the critical section, and no interrupts or smgr functions relating > * to this relation should be called in between. > + * > + * If the specified number of blocks is higher than the current size, the > + * request is ignored when we are InRecovery, otherwise, an error is raised. > */ > void > smgrtruncate(SMgrRelation reln, ForkNumber *forknum, int nforks, I would love to have a comment along those lines, but I think it's misleading here, because smgrtruncate() actually does a few things even when the requested size is greater than the current size: it nevertheless calls DropRelationBuffers(), CacheInvalidateSmgr(), and updates the cached sizes in the SmgrRelation. So it seems misleading to say the request is ignored. I wasn't sure how to phrase that, so I just left out that comment change. I'm open to proposals on a good wording though. (The similar comment in mdnblocks() is accurate, mdnblocks() bails out very early, so I kept that) - Heikki