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.98.2) (envelope-from ) id 1xLLlQ-00000001SXN-1v39 for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Oct 2026 14:33:29 +0000 Received: from localhost ([127.0.0.1]:42462 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xLLlP-00000005nYA-3YpG for pgsql-hackers@arkaria.postgresql.org; Mon, 26 Oct 2026 14:33:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]:39464) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xLLlP-00000005nY0-1UVc for pgsql-hackers@lists.postgresql.org; Mon, 26 Oct 2026 14:33:27 +0000 Received: from mail-4318.protonmail.ch ([185.70.43.18]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xLLlM-000000011so-2QMC for pgsql-hackers@postgresql.org; Mon, 26 Oct 2026 14:33:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; s=protonmail; t=1793025200; x=1793284400; bh=28OCFeSWXTZIm1BrPVL8iVu85Itix9SSToClEH2Y/Lk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=qYVHBp22Gce1WPHMYtAmFvCY7z8PuER7vrYyNtaBL9SA7p2x0RGa38OMR8ZcwzGhN 6pivua03H9ak/FxNcm3jwY/MERqIRoOGhGSI1uO3VMWSJFLhnDOwbL7uprLOl3BCWP NzSOmnKkqyDAlrHnQ7YFvrX9HVee6sjW9X+WByvXChJzOeDbbpGzcp3AJHE+UPZ6wc 6hi24bwV7I+D7ve1a0ZJRqP4YIMfekY/fAgouTMXZuL/745XQ8BurSOkJnmKPHj0AO IwEhDv/iwGbQCtM5ANiE62G5UudH6+h6DNDEUTp52d/YnAm1pH6svotsgRZY3OJs2V iQuTyOPpWHktg== Date: Mon, 26 Oct 2026 14:33:16 +0000 To: pgsql-hackers@postgresql.org From: Greg Burd Cc: andres@anarazel.de, michael@paquier.xyz, greg@burd.me, pgsql@j-davis.com, thomas.munro@gmail.com, exclusion@gmail.com, amit.kapila16@gmail.com, hlinnaka@iki.fi Subject: Re: WAL record CRC calculated incorrectly because of underlying buffer modification Message-ID: In-Reply-To: References: Feedback-ID: 2668248:user:proton X-Pm-Message-ID: 781b41d5dd8d13cd2c8459b41221af37c7922643 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2026-10-26 Michael Paquier wrote: > I'm finding the comments a bit over-complicated, so I've adjusted > these as of the attached. What do you think? Hey Michael, First, thanks for taking a look so fast and for offering a solid review and revision of the patch I proposed. I'll use your wording, it is far better than mine. The one thing I'd keep from the longer version is a pointer from verifyBackupPageConsistency() to the exact line in XLogRecordAssemble() that decides to omit the image, since the two have to stay in agreement and they're far apart in the file. A half-line is enough: /* no image was taken (REGBUF_NO_CHANGE in XLogRecordAssemble); skip *= / > So let's leave it at v17~ where the regbuf flag exists. Agreed, drop v14-16. I'd floated the back-branch version, but the only thi= ng it buys there is making wal_consistency_checking=3D'hash' not crash a stand= by, and on reflection that's not worth inventing a pin-only detection path thos= e branches don't otherwise need. On 2026-10-26 Andres Freund wrote: > I frankly think it's pretty much unacceptable for a niche index like hash > to violate the rules like that. > [...] > It's probably the best answer in the back branches, but I think we > shouldn't do this in master. Hey Andres, Thanks for taking the time to review, I'm curious why you used the term "niche" with hash indexes. Not related to this topic, just an aside. You're right, the real problem is hash CRCs a page it holds only a pin on, = so another backend can change it under the record. The clean fix is to make t= he three call sites (hashbucketcleanup, _hash_freeovflpage, _hash_squeezebucke= t) stop reading a page they don't content-lock and either take the buffer the normal way, or follow the XLogSaveBufferForHint() protocol Jeff pointed at. Where I'd push back is on making that the gate for master while the standby crash stays unfixed. Two things make me want the small fix in master too, = not only the back branches: 1. REGBUF_NO_CHANGE's contract already is "pinned, not content-locked, not modified here". Taking a full-page image of such a block under XLR_CHECK_CONSISTENCY contradicts that contract on its own terms: there's nothing to consistency-check on a block the record doesn't change, and the page isn't safe to read while assembling the record. So skipping the image isn't only a hash workaround it makes the consistency-check path honor the flag's definition. Any future code that legitimately registers a pin-only block hits the same assertion today. 2. If master keeps taking the image and the hash rework lands later, the rework has to touch the same three sites anyway, and in the meantime master is the one branch where wal_consistency_checking=3D'hash' faults= . Fixing the flag's behaviour in master and doing the hash rework as a follow-up are not in tension, the rework doesn't depend on the image still being taken. Concretely, here's what I propose: - master and v17+: the minimal fix (skip the image for REGBUF_NO_CHANGE, with Michael's comments). This stops the standby crash on every branch that has the flag and makes the consistency check match the contract. - master, separate patch: make hash stop modifying pin-only buffers at th= e three sites, so hash follows the buffer rules and the REGBUF_NO_CHANGE = | REGBUF_NO_IMAGE dance for "just force a cleanup lock" is no longer needed. I'm willing to write this; it's the non-trivial part, and I'd rather it be reviewed on its own than bundled with the crash fix. If you'd still rather master not carry the flag-level fix at all and wait f= or the hash rework, I can live with that but then I'd want the rework to be th= e thing we track for master now, not a someday item, because the crash is liv= e on master today. Which of those do you prefer? I'll hold the back-branch patches and post a v-next of the master patch wit= h Michael's comments once we've settled master-only-rework vs flag-fix-plus-rework. best, -greg