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 1kVZRk-0003fG-UH for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Oct 2020 12:11:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVZRh-0004bd-CG for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Oct 2020 12:11:53 +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 1kVZRg-0004bW-Qd for pgsql-hackers@lists.postgresql.org; Thu, 22 Oct 2020 12:11:52 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kVZRd-0002Vc-6C for pgsql-hackers@postgresql.org; Thu, 22 Oct 2020 12:11:51 +0000 Received: from [192.168.1.70] (ppp91-76-194-158.pppoe.mtu-net.ru [91.76.194.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 2155A21C33E5; Thu, 22 Oct 2020 15:11:46 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1603368706; bh=2KmNwWKzvo7ReLix2I9OOjIq8A6p8bdNOqIFYvbe6Sk=; h=Subject:To:Cc:References:From:Date:In-Reply-To; b=g6ZL+tCw1SaEXyqEBYtLtL/VcvGdWAxtMUYtI+iWcNlLSnUaOq5xHZPAqCIOd/Nxj /thTlXP5xFywEGW7uYI1fvsEoWq9lXBntM7uKeYUA5ovvXiBHjpVTg5RoCJ2vsNXz+ Afvvx2j1v4/YnaKKTmSnB5LTi/fnxu8HzeB+hhX0= Subject: Re: [patch] Fix checksum verification in base backups for zero page headers To: Michael Paquier Cc: Michael Banck , PostgreSQL Development References: <2439c2d6cee13d611e23ba651e5eb4ab0469bf99.camel@credativ.de> <4b1c16216dcb60e1dad96142d25fd06fb77485bf.camel@credativ.de> <6713b5e9d98c7db1608b43cd57b10be4a08dca67.camel@credativ.de> <9489c221-e2ef-e7ad-d921-5ccad71b14de@postgrespro.ru> <423deac52479a40624e775e6d2ab41c4e9f5b19f.camel@credativ.de> <20201007081852.GC30037@paquier.xyz> <608f3476-0598-2514-2c03-e05c7d2b0cbd@postgrespro.ru> <20201020062432.GA30362@paquier.xyz> <69b38451-e91f-95fc-c3ce-06eb778d36e0@postgrespro.ru> <20201022012519.GF1475@paquier.xyz> From: Anastasia Lubennikova Message-ID: <036235b4-2461-c4b2-a448-7875d943ce1e@postgrespro.ru> Date: Thu, 22 Oct 2020 15:11:45 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201022012519.GF1475@paquier.xyz> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 22.10.2020 04:25, Michael Paquier wrote: > On Thu, Oct 22, 2020 at 12:47:03AM +0300, Anastasia Lubennikova wrote: >> We can also read such pages via shared buffers to be 100% sure. > Yeah, but this has its limits as well. One can use > ignore_checksum_failure, but this can actually be very dangerous as > you can finish by loading into shared buffers a page that has a header > thought as sane but with a large portion of its page randomly > corrupted, spreading corruption around and leading to more fancy > logic failures in Postgres, with more panic from customers. Not using > ignore_checksum_failure is safer, but it makes an analyze of the > damages for a given file harder as things would stop at the first > failure of a file with a seqscan. pg_prewarm can help here, but > that's not the goal of the tool to do that either. I was thinking about applying this only to pages with LSN > startLSN. Most of such pages are valid and already in memory, because they were changed just recently, so no need for pg_prewarm here. If such LSN appeared because of a data corruption, page verification from inside ReadBuffer() will report an error first. In proposed function, we can handle this error in any fashion we want. Something like: if (PageGetLSN(page) > startptr) {     if (!read_page_via_buffercache())         //throw a warning about corrupted page         //handle checksum error as needed     else         //page is valid. No worries } -- Anastasia Lubennikova Postgres Professional: http://www.postgrespro.com The Russian Postgres Company