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 1k2j9x-0003VC-5C for pgsql-general@arkaria.postgresql.org; Mon, 03 Aug 2020 22:42:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k2j9v-0002Q1-Ab for pgsql-general@arkaria.postgresql.org; Mon, 03 Aug 2020 22:42:19 +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 1k2j9u-0002Pp-JS for pgsql-general@lists.postgresql.org; Mon, 03 Aug 2020 22:42:18 +0000 Received: from dog.birch.relay.mailchannels.net ([23.83.209.48]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k2j9o-00078e-2G for pgsql-general@postgresql.org; Mon, 03 Aug 2020 22:42:15 +0000 X-Sender-Id: a2hosting|x-authuser|bench@silentmedia.com Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 20D8A921532; Mon, 3 Aug 2020 22:42:10 +0000 (UTC) Received: from a2ss24.a2hosting.com (100-96-7-27.trex.outbound.svc.cluster.local [100.96.7.27]) (Authenticated sender: a2hosting) by relay.mailchannels.net (Postfix) with ESMTPA id 77E82921416; Mon, 3 Aug 2020 22:42:09 +0000 (UTC) X-Sender-Id: a2hosting|x-authuser|bench@silentmedia.com Received: from a2ss24.a2hosting.com (a2ss24.a2hosting.com [75.98.175.117]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384) by 0.0.0.0:2500 (trex/5.18.8); Mon, 03 Aug 2020 22:42:10 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: a2hosting|x-authuser|bench@silentmedia.com X-MailChannels-Auth-Id: a2hosting X-Society-Abaft: 3d4aff49434fe473_1596494529920_519275278 X-MC-Loop-Signature: 1596494529920:3051491603 X-MC-Ingress-Time: 1596494529920 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=silentmedia.com; s=default; h=Content-Type:In-Reply-To:MIME-Version:Date: Message-ID:From:References:Cc:To:Subject:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=0W1Sl7I3s5ddyuqbJ8lr+ybrHVu56dCJVkfyE6RNXWc=; b=tIJUW4Kma9VxAX8JaLsya/ifR 0iEXMI2g0yy4QpRvSy3zhHFMLUS31kYmZ1enz6XBbTQxkGkjxXEE/Cp6IXVVaeejbJKKKwaIquiFV o2Gmewcqa6SS3hm0WvbgzUMre2u1ij8XPBdt1vDNDYhrZco1ICI7jsOjaH0o1HDvVEafy3/plYdNI lv4oVXUEryUG5w4HSjqECC+36Cl60EWeHGZghftJODC6t5QgP3US9UyjoaM16uFZMkNOYbuSerEcu sJJNDnzDpUXfAaI6cb5xqjeWdlCAE0LwadRCGdjaoX+4sOvpKPVKfhOoG0b72KaO2uW0fJVqI2RMg +o7n1ldbQ==; Received: from 174-21-131-86.tukw.qwest.net ([174.21.131.86]:54824 helo=Rolo.local) by a2ss24.a2hosting.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1k2j9k-005nyx-Aq; Mon, 03 Aug 2020 18:42:08 -0400 Subject: Re: 12.3 replicas falling over during WAL redo To: Alvaro Herrera Cc: pgsql-general References: <20200803213454.GA32739@alvherre.pgsql> From: Ben Chobot Message-ID: <9ba2cbd8-fa0b-cdd9-3eea-26b5418f20ce@silentmedia.com> Date: Mon, 3 Aug 2020 15:42:06 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:52.0) Gecko/20100101 PostboxApp/7.0.25 MIME-Version: 1.0 In-Reply-To: <20200803213454.GA32739@alvherre.pgsql> Content-Type: multipart/alternative; boundary="------------7E72C58F59D24210FCBA9915" Content-Language: en-US X-AuthUser: bench@silentmedia.com List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------7E72C58F59D24210FCBA9915 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Alvaro Herrera wrote on 8/3/20 2:34 PM: > On 2020-Aug-03, Ben Chobot wrote: > >> Alvaro Herrera wrote on 8/3/20 12:34 PM: >>> On 2020-Aug-03, Ben Chobot wrote: >>> >>> Yep. Looking at the ones in block 6501, >>> >>>> rmgr: Btree       len (rec/tot):     72/    72, tx:   76393394, lsn: >>>> A0A/AB2C43D0, prev A0A/AB2C4378, desc: INSERT_LEAF off 41, blkref #0: rel >>>> 16605/16613/60529051 blk 6501 >>>> rmgr: Btree       len (rec/tot):     72/    72, tx:   76396065, lsn: >>>> A0A/AC4204A0, prev A0A/AC420450, desc: INSERT_LEAF off 48, blkref #0: rel >>>> 16605/16613/60529051 blk 6501 >>> My question was whether the block has received the update that added the >>> item in offset 41; that is, is the LSN in the crashed copy of the page >>> equal to A0A/AB2C43D0? If it's an older value, then the write above was >>> lost for some reason. >> How do I tell? > You can use pageinspect's page_header() function to obtain the page's > LSN. You can use dd to obtain the page from the file, > > dd if=16605/16613/60529051 bs=8192 count=1 seek=6501 of=/tmp/page.6501 If I use skip instead of seek.... > then put that binary file in a bytea column, perhaps like > > create table page (raw bytea); > insert into page select pg_read_binary_file('/tmp/page'); > > and with that you can run page_header: > > create extension pageinspect; > select h.* from page, page_header(raw) h;      lsn      | checksum | flags | lower | upper | special | pagesize | version | prune_xid --------------+----------+-------+-------+-------+---------+----------+---------+-----------  A0A/99BA11F8 |     -215 |     0 |   180 |  7240 |    8176 |     8192 |       4 |         0 As I understand what we're looking at, this means the WAL stream was assuming this page was last touched by A0A/AB2C43D0, but the page itself thinks it was last touched by A0A/99BA11F8, which means at least one write to the page is missing? --------------7E72C58F59D24210FCBA9915 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Alvaro Herrera wrote on 8/3/20 2:34 PM:
On 2020-Aug-03, Ben Chobot wrote:

Alvaro Herrera wrote on 8/3/20 12:34 PM:
On 2020-Aug-03, Ben Chobot wrote:

Yep. Looking at the ones in block 6501,

rmgr: Btree       len (rec/tot):     72/    72, tx:   76393394, lsn:
A0A/AB2C43D0, prev A0A/AB2C4378, desc: INSERT_LEAF off 41, blkref #0: rel
16605/16613/60529051 blk 6501
rmgr: Btree       len (rec/tot):     72/    72, tx:   76396065, lsn:
A0A/AC4204A0, prev A0A/AC420450, desc: INSERT_LEAF off 48, blkref #0: rel
16605/16613/60529051 blk 6501
My question was whether the block has received the update that added the
item in offset 41; that is, is the LSN in the crashed copy of the page
equal to A0A/AB2C43D0?  If it's an older value, then the write above was
lost for some reason.
How do I tell?
You can use pageinspect's page_header() function to obtain the page's
LSN.  You can use dd to obtain the page from the file,

dd if=16605/16613/60529051 bs=8192 count=1 seek=6501 of=/tmp/page.6501 

If I use skip instead of seek....

then put that binary file in a bytea column, perhaps like

create table page (raw bytea);
insert into page select pg_read_binary_file('/tmp/page');

and with that you can run page_header:

create extension pageinspect;
select h.* from page, page_header(raw) h;

     lsn      | checksum | flags | lower | upper | special | pagesize | version | prune_xid
--------------+----------+-------+-------+-------+---------+----------+---------+-----------
 A0A/99BA11F8 |     -215 |     0 |   180 |  7240 |    8176 |     8192 |       4 |         0

As I understand what we're looking at, this means the WAL stream was assuming this page was last touched by A0A/AB2C43D0, but the page itself thinks it was last touched by A0A/99BA11F8, which means at least one write to the page is missing?
--------------7E72C58F59D24210FCBA9915--