Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZfbe-0001tL-Q5 for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Nov 2020 19:35:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kZfbd-00040j-Pc for pgsql-hackers@arkaria.postgresql.org; Mon, 02 Nov 2020 19:35:05 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZfbc-0003z3-4V for pgsql-hackers@lists.postgresql.org; Mon, 02 Nov 2020 19:35:05 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kZfbZ-0006nl-7T for pgsql-hackers@lists.postgresql.org; Mon, 02 Nov 2020 19:35:03 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id A8E975C0196; Mon, 2 Nov 2020 14:34:59 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute1.internal (MEProxy); Mon, 02 Nov 2020 14:34:59 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm3; bh=2nMD7GPTwHXzZ1gbJiyly2aagya aG+RanIHlDTRJWnM=; b=M3cZzOBYAqleq/aJthEXMeOgjtuwPPFZth5ppIPM7k4 3L1BhUua+HyIScebsMJdRux0F1gfRPPnopyMGkJNwYqpr+CW/2Nr9I390lyN28qW 3Y6J5+eKj6ZJPgA8K2BfooMuSdXe680CggO660Hefkr1Zbb06w89HUsBxTHNZq7k 5TKVQA/Ed7HeYzIVsp9iQXMqIoAa4O/GtSgmwZBGLoBwKhviO5dTHDKh7vZHi12R iBMG+kmNmHaxRbwFrbhFGNTVd9FENLphJDjBSSSDXpfMe5IvcGCAaef6FYMsEUi5 25AYShE8iC9RALKjrV7c13c8mfLlAM2mUHmjS6VEP/w== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=2nMD7G PTwHXzZ1gbJiyly2aagyaaG+RanIHlDTRJWnM=; b=KK6i1TTqhSbxiKbjlJhRhp e/AWl8SqCeVDvDsI4o/r05jxJm+413+GsIc3Q7uuYT2tvgoCxSWWzXGLX/RWwjrI YiPnaPSwkPJIIKKCmIVziBONkMcyf/Vn3SJzEpmPhXpycM8zlL6KMgvz70mN0JLg KeB5mvJQVCfqOQxE793CIpe+1uPJLW6KpRZwW4JOC4HGR5XAk1Me9AQcrtJXltGv q5zN2EIgK8wi/X3NLPmSb8K51x6XUXkybllwdsH8jHndt1TTcoCI2K2QLHOUuIbC qC7dtOFzb2If/HF9dTrp13T7ZBbcMDGXuKK8T1ejQaWZQThCc/4VEBJRV/PQnl1w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedujedruddtuddguddviecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepudekhfekleeugeevteehleffffejgeelueduleeffeeutdelffeujeff hfeuffdunecukfhppeeijedrudeitddrvddujedrvdehtdenucevlhhushhtvghrufhiii gvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrnhgurhgvshesrghnrghrrgiivghl rdguvg X-ME-Proxy: Received: from intern.anarazel.de (c-67-160-217-250.hsd1.ca.comcast.net [67.160.217.250]) by mail.messagingengine.com (Postfix) with ESMTPA id CD1823064674; Mon, 2 Nov 2020 14:34:58 -0500 (EST) Date: Mon, 2 Nov 2020 11:34:57 -0800 From: Andres Freund To: Robert Haas Cc: Michael Paquier , Julien Rouhaud , Justin Pryzby , Masahiko Sawada , PostgreSQL Hackers , Masahiko Sawada Subject: Re: Online checksums verification in the backend Message-ID: <20201102193457.fc2hoen7ahth4bbc@alap3.anarazel.de> References: <20201019075248.GD9612@paquier.xyz> <20201023072832.GE5180@paquier.xyz> <20201023090630.GA26347@paquier.xyz> <20201027070746.GD28445@paquier.xyz> <20201028050852.GF28445@paquier.xyz> <20201029181729.2nrub47u7yqncsv7@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, On 2020-11-02 12:35:30 -0500, Robert Haas wrote: > On Thu, Oct 29, 2020 at 2:17 PM Andres Freund wrote: > > I think this needs to be quickly reworked or reverted. I think it's fairly clear by now that revert is appropriate for now. > I don't like this patch, either. In addition to what Andres mentioned, > CheckBuffer() is a completely-special case mechanism which can't be > reused by anything else. In particular, the amcheck for heap stuff > which I recently committed (866e24d47db1743dfcff5bd595b57e3a143f2cb1) > would really like a way to examine a buffer without risking an error > if PageIsVerified() should happen to fail, but this patch is of > absolutely no use in getting there, because CheckBuffer() doesn't give > the caller any way to access the contents of the buffer. It can only > do the checks that it knows how to do, and that's it. That doesn't > seem like a good design. Wouldn't this be better served by having a ReadBufferExtended() flag, preventing erroring out and zeroing the buffer? I'm not sure that handling both the case where the buffer contents need to be valid and the one where it doesn't will make for a good API. > I don't like the fact that CheckBuffer() silently skips dirty buffers, > either. The comment should really say that it checks the state of a > buffer without loading it into shared buffers, except sometimes it > doesn't actually check it. Yea, I don't see a good reason for that either. There's reasons for dirty buffers that aren't WAL logged - so if the on-disk page is broken, a standby taken outside pg_basebackup would possibly still end up with a corrupt on-disk page. Similar with a crash restart. > If the buffer is in shared buffers, we could take a share-lock > on the buffer and copy the contents of the page as it exists on disk, > and then still check it. Don't think we need a share lock. That still allows the buffer to be written out (and thus a torn read). What we need is to set BM_IO_IN_PROGRESS on the buffer in question - only one backend can set that. And then unset that again, without unsetting BM_DIRTY/BM_JUST_DIRTIED. > It feels really confusing to me that the user-exposed function here is > called pg_relation_check_pages(). How is the user supposed to > understand the difference between what this function does and what the > new verify_heapam() in amcheck does? The answer is that the latter > does far more extensive checks, but this isn't obvious from the SGML > documentation, which says only that the blocks are "verified," as if > an end-user can reasonably be expected to know what that means. It > seems likely to lead users to the belief that if this function passes, > they are in good shape, which is extremely far from being true. Just > look at what PageIsVerified() checks compared to what verify_heapam() > checks. Yea I had similar thoughts, it should just be called pg_checksum_verify_relation() or something. > In fact, I would argue that this functionality ought to live in > amcheck rather than core, though there could usefully be enabling > functions in core. I'm not really convinced by this though. It's not really AM specific - works for all types of relations with storage; don't really object either... Greetings, Andres Freund