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 1vpXLH-00AdTw-1t for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 19:54:43 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vpXLG-00CGQb-17 for pgsql-hackers@arkaria.postgresql.org; Mon, 09 Feb 2026 19:54:42 +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 1vpXLG-00CGQT-0A for pgsql-hackers@lists.postgresql.org; Mon, 09 Feb 2026 19:54:41 +0000 Received: from mail-qt1-x832.google.com ([2607:f8b0:4864:20::832]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vpXLD-00000001K5n-3GCZ for pgsql-hackers@postgresql.org; Mon, 09 Feb 2026 19:54:40 +0000 Received: by mail-qt1-x832.google.com with SMTP id d75a77b69052e-5032e951106so501791cf.0 for ; Mon, 09 Feb 2026 11:54:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770666879; cv=none; d=google.com; s=arc-20240605; b=kPb7OV6K6kjq0dOgFKQi+hPbyJa2qvMy7SccByKTcJny7yfYFnK+fri/GyZkzW+B/J VF3mpW30EVrHRjdZMDCxXtdO7HJ9a0ruHHWvM0pUx06arsdFpmJydidc+VRYKZh+8oQU xCMMyQLH+OgMxCgP1mhE0AK27UtAPFM44MTe/hoApMoupyev7P/9Yi1kRwDAiuDYTy8Q IvNlbkSdo+sz1rHf+45UsW4zceVTUvi//+X/9r7q5wTZDIAn3ysmR2M+eyO8ro+gvGMf 39xzWDJwMbl3c18SuxsIbGxDUSDWGwDR9+CpK2Qy+qQ87gqXISPk7eTlCGsWWdNxiB44 hnDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:dkim-signature; bh=z2CxD4DsRPytnmgxlYnpdZuuDfxDM8e6i9PyrwtBN2g=; fh=EBR+hslpms8E5SfUD2Uw+W9drvQdYBi1qEvpCQES9WI=; b=AIQxoQ4g+y6V4W57xHB5ZrhsLXPdPuEFJrN3kmL7YXLuI4642ZDbln4bY5gt09qi6b KuGBYX+HmFApqaIzlhbpZQl/8jalHlCQqS95x7xxJjruZMTlgs5rKf0bzzpqpvY6DVOb oUw3HhOmGZq8n/XX3/LGa3zZRqfEie+9DMQJRbD0t0iAIXViFS4wgZPKsxxSrHdzcOqr GBnsHFduhnrImOzwUv/v1Xom+WVitr+o5sr4v383umrmRGjH8ihGtMFHTLvwga30IFyc l0v/ndNVs8MteD5tdFedVj4kiIM82Z5GJGrzGQIbm48m752j4aMAJyusb7LlQ8VnqNb1 AtuA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770666879; x=1771271679; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=z2CxD4DsRPytnmgxlYnpdZuuDfxDM8e6i9PyrwtBN2g=; b=OAMXU2qXSla8aWkeLvriOBg42VMQLl0y0aGHfK1nluTEtGqx0+Nrg0IwvPBJGj5cW6 rOw1ertU/NFzYfxoNoy1+p5MRdTcpwu3E+0m+rPvJnrx57uOe+/8A8SZy1nmd+kKYPr3 /za+D4+wKocdPPT06+jqQfwNA2YYaipCOUc1KWP4Fr0BTIXK+9bAt0fnf3jVxMpFTskK 16og8a4PV2KqktZO0Akin79MTMKCW4Y808yIalWH3hJMbp7l1rl7eQ2frkpN729MMF+C R+CCh9wwtE4bsP1RnPjFGgzcGtF5+7krSemY1i1LFN+MzIIkQS73X2H2wWdVQfkuI04P sFvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770666879; x=1771271679; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=z2CxD4DsRPytnmgxlYnpdZuuDfxDM8e6i9PyrwtBN2g=; b=KqxXYUweeQ/iqtB/h9ZV+yrM+BxjK0yk5Q/1KOAYFqtKzavlb2697vMjomx5APkRAf gM1GOeBuGDbUtCsi/7PqkTDGZGFnUgGXWyQ+KY40uoSE7+agPwlnYAlNOwRVZD+C9zIp af2242a6vtFlZamE/YZlKAILo+9mK0LuhQp7sv9g04UHHxgrUkv9C608/qKQnZO5ckAp 9hHrNW5VkyyCkTzwhMdqXFH7XpkMNIEXxWy+OGJ3XWSVV1RvI7CKJU4Zy/kI/VLw9Ud3 QX7YSn2j9rE6GTZ1q4aDQSWe4uPMwC2SmECBFcrduVBZ6tSeT8H7WF6oXjrxhd+80dT9 uIDQ== X-Forwarded-Encrypted: i=1; AJvYcCU9BKngyJputnfbwKCTM7gFHBnTNXVSGqt5gESuiziyezdunZNK3vwU6jS2cyiyLuuQOjmv1duinjFCviv8@postgresql.org X-Gm-Message-State: AOJu0YxU1lZg9UHW+u1bcTVXV5ODTBOTxUk/SunrAzo63ynd3GHwDDp5 lNL1/+C0hND0QnAQHdUb81k9CemzdNHnWwYsk0xeFKm5UMQmt60BFKWucqlxvFfTLsaWCE7oWsS p9btVKOkwPV69X2+AWUFteYeE40IogA8= X-Gm-Gg: AZuq6aKkYNmnAxl/dVhy8J9VcsXjEsQ6OaO73sfdj0G47JaGFKUdsOpjaf3szq91Gw3 PdDU7zN+DY2pHv7MAs0mcwWwVDSlvTDl9LkJxP2Lzl5dmmA4fscvYmugbOS4r00Ep8rhOFQBhTK weJuVkGAbM5XlHy/5CcWAbJw9MEs8FhGMG4BsAYuzIi9baij714dkAHTIaRY2ek6SQ0IuHOUiC5 XdMczUymfvv8Q4lHNWlduUtAsX1FfUl6IlSp8g4Lb+XERySrq+TviL6idIQLTSpEEtIHHeAEp+R JFoda4rTCG5UQCh5oVUR6IV2i2nLeb1c/k4pXdeehD2FS9SPOmSEo0/sBK+/NbzwEYHzvQ== X-Received: by 2002:ac8:7d05:0:b0:501:466b:5141 with SMTP id d75a77b69052e-50639892506mr177532281cf.18.1770666878797; Mon, 09 Feb 2026 11:54:38 -0800 (PST) MIME-Version: 1.0 References: <1108f18d-cf7c-4f17-b29c-a119fe42f7e5@iki.fi> <5dwlfu2jyzkyf3nrlzxxblxctb6xio5es73ptgsahjnmfu5miu@772rc764hfhi> <4csodkvvfbfloxxjlkgsnl2lgfv2mtzdl7phqzd4jxjadxm4o5@usw7feyb5bzf> <5ubipyssiju5twkb7zgqwdr7q2vhpkpmuelxfpanetlk6ofnop@hvxb4g2amb2d> <03041d48-1e15-4741-b365-0809f2bc75c4@iki.fi> In-Reply-To: From: Kirill Reshke Date: Tue, 10 Feb 2026 00:54:27 +0500 X-Gm-Features: AZwV_QjAUxJQQduA5x3wprV2KoJlNAHVN6_RU0exwZ6-RTR84YgetYJDstnofYA Message-ID: Subject: Re: Buffer locking is special (hints, checksums, AIO writes) To: Andres Freund Cc: Heikki Linnakangas , Melanie Plageman , Noah Misch , Matthias van de Meent , pgsql-hackers@postgresql.org, Thomas Munro , Robert Haas , Michael Paquier Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sun, 8 Feb 2026 at 23:38, Andres Freund wrote: > > Consider: > > 1) modify page w/ FPI > 2) redo pointer determined at X > 3) modify page w/o FPI, as the page hasn't yet been flushed at X+1 > 4) checkpointer flushes page > 5) checkpoint completes, at X+2 > 6) page is dirtied, w/o FPI X+3, as X+1 > X > 7) in the middle of writing out the page, we crash, the page is torn > > For recovery we will replay starting from position X. Then will replay the > record from 3), which will be skipped due to the LSN. Then we will replay X+3, > which either will be skipped due to the LSN condition (if the page header > survived the torn page), leading to the changes to the "old portion" of the > torn page not being replayed, or we will replay the WAL record, applying it to > a torn page (or failing to read in the page due to checksum errors). > > If we only needed to think about buffers that stay in memory, we could "just" > tackle this by remember that the page will need to be FPId during the next > modification in the BufferDesc, but that doesn't help us if the page is > evicted and reread... > > Hmm, after thinking about this, I wonder if we can actually have a TAP test for this sequence of events? Maybe it would be desirable to execute some rare recovery code path. But I'm unsure if there is any reliable way to have an OS to have a buffer in page cache, but not on disk when evicted. -- Best regards, Kirill Reshke