Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f84O9-0002PY-Do for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Apr 2018 13:41:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f84O8-0004i4-Ay for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Apr 2018 13:41:44 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f84O7-0004hC-UP for pgsql-bugs@lists.postgresql.org; Mon, 16 Apr 2018 13:41:44 +0000 Received: from mail-wr0-x244.google.com ([2a00:1450:400c:c0c::244]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1f84O4-0002u3-7F for pgsql-bugs@postgresql.org; Mon, 16 Apr 2018 13:41:42 +0000 Received: by mail-wr0-x244.google.com with SMTP id z73so26165278wrb.0 for ; Mon, 16 Apr 2018 06:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=e550eSJio4n9pv5SbTSXELGdszmgypOGjyXmakqWk1s=; b=FuVndg4t007JAFqQgb8ORxxQsApfp/v8UxGVwDcidAYJ6eQcNXgQg1MMSBPNGGuSmm PXuNDzHd8zsRyycJuvELUHA17NkB/j7FggX52q7aiuCbS7jubsXD8vNtnBXUwavIqELR O2tP56bd2AUEWSd5BAoVOzOJG5HnwjLdZONhtnw+QRP8AB5q8+YN9GiSMSFyJegCFMwk 6cA03EsMgiOqCVF+v8nB5oVfZQiBUQIsFtC2dW0CZrGHavG1YjMuMtCbogz4UxrD+1rO bhrCEtfbE+s67CV8nnxfVVODkVu/4kBfRBS+Ju2hVoaAw/PEyHBIjQpSBNH3YNbqdj1D P+Cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=e550eSJio4n9pv5SbTSXELGdszmgypOGjyXmakqWk1s=; b=PVx+Vbuu+/sBbWpEXDJeYv247IQc75R72dZJihdUYmv3bqvIftWQGUHn3W0InUxJeu U7/K5BAamb1sDiTMta4F5RI+1v9oLyVI0fkuaK6J3MtfXDuHZmjeXpI0RUhRfi3y6Sk5 1AvDwWh15t+aFMFW2DZv7m1JjAsl7XJw1R2cKasGXHyRxtfub7pjCAJgA/zTORddP46G 7bvgMVnLuMocb9Y4yRJVB8QtAfEN664YYC6UxhqRbWT4bNkdHcdN7ULjXt3QYpkyh7m3 rHFpPz5b55t6+AZ+vixCBU/JRsjxmCyTJ+jgi0Ms+m5e4vREu3GIRCCJAHS+60uK2t1z 2eNg== X-Gm-Message-State: ALQs6tBQRm4/7MY9ygyWqY2WJFLcIdgAhlYCJQgAkL7+pLwJWSEPSSTL GHkVEJNTbc0p30/RPMnKN9w7GC74 X-Google-Smtp-Source: AIpwx4/LVLBW8WHrUlIgslBChAOnS5z5YZOlrXfEV1F9wMvieojop5SkysaBkD1nevkSs3mZ38NDEA== X-Received: by 10.28.211.79 with SMTP id k76mr1096383wmg.110.1523886098215; Mon, 16 Apr 2018 06:41:38 -0700 (PDT) Received: from [10.137.2.19] (ip-78-102-97-226.net.upcbroadband.cz. [78.102.97.226]) by smtp.gmail.com with ESMTPSA id j89sm8155477wrj.86.2018.04.16.06.41.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Apr 2018 06:41:37 -0700 (PDT) Subject: Re: Standby corruption after master is restarted To: emre@hasegeli.com Cc: PostgreSQL Bugs , gurkan.gur@innogames.com, david.pusch@innogames.com, patrick.schmidt@innogames.com References: From: Tomas Vondra Message-ID: Date: Mon, 16 Apr 2018 15:41:34 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 04/16/2018 10:55 AM, Emre Hasegeli wrote: >> In the initial report (from August 2018) you shared pg_xlogdump output, >> showing that the corrupted WAL record is an FPI_FOR_HINT right after >> CHECKPOINT_SHUTDOWN. Was it the same case this time? > > No, this time the xlogdump on master looks like this: > >> rmgr: Heap2 len (rec/tot): 110/ 110, tx: 0, lsn: 1DFB/D6BDDF20, prev 1DFB/D6BDDEE0, desc: CLEAN remxid 0, blkref #0: rel 1663/16385/141744 blk 331540 >> rmgr: Heap2 len (rec/tot): 100/ 100, tx: 0, lsn: 1DFB/D6BDDF90, prev 1DFB/D6BDDF20, desc: CLEAN remxid 0, blkref #0: rel 1663/16385/141744 blk 331541 >> rmgr: XLOG len (rec/tot): 106/ 106, tx: 0, lsn: 1DFB/D6BDDFF8, prev 1DFB/D6BDDF90, desc: CHECKPOINT_SHUTDOWN redo 1DFB/D6BDDFF8; tli 5; prev tli 5; fpw true; xid 2/3522301709; oid 141900; multi 3434; offset 7985; oldest xid 3329390243 in DB 16385; oldest multi 1 in DB 16385; oldest/newest commit timestamp xid: 0/0; oldest running xid 0; shutdown >> rmgr: Heap len (rec/tot): 56/ 2511, tx: 3522301709, lsn: 1DFB/D6BDE080, prev 1DFB/D6BDDFF8, desc: INSERT off 93, blkref #0: rel 1663/40796/40826 blk 0 FPW >> rmgr: Transaction len (rec/tot): 34/ 34, tx: 3522301709, lsn: 1DFB/D6BDEA50, prev 1DFB/D6BDE080, desc: COMMIT 2018-03-28 14:01:36.800811 UTC >> rmgr: Heap len (rec/tot): 56/ 1257, tx: 3522301710, lsn: 1DFB/D6BDEA78, prev 1DFB/D6BDEA50, desc: INSERT off 41, blkref #0: rel 1663/40796/40820 blk 345119 FPW >> rmgr: Btree len (rec/tot): 55/ 1857, tx: 3522301710, lsn: 1DFB/D6BDEF68, prev 1DFB/D6BDEA78, desc: INSERT_LEAF off 125, blkref #0: rel 1663/40796/40839 blk 107903 FPW >> rmgr: Transaction len (rec/tot): 34/ 34, tx: 3522301710, lsn: 1DFB/D6BDF6B0, prev 1DFB/D6BDEF68, desc: COMMIT 2018-03-28 14:01:37.361010 UTC > OK, and on the standby? I suppose it breaks right after the CHECKPOINT_SHUTDOWN record, right? >> BTW which versions are we talking about? I see the initial report >> mentioned catversion 201608131, this one mentions 201510051, so I'm >> guessing 9.6 and 9.5. Which minor versions? > > The first incident was on 9.6.3, the second 9.5.7. > >> Is the master under load (accepting writes) before shutdown? > > Yes. Especially on the second incident it was being written heavily. > The master gets up to 10k INSERT transactions per second before being > killed. > >> How was it restarted, actually? I see you're mentioning OOM killer, so I >> guess "kill -9". What about the first report - was it the same case, or >> was it restarted "nicely" using pg_ctl? > > On the first incident the master was being restarted as part of > upgrade from 9.6.3 to 9.6.4. It should have been nicely done by the > Debian upgrade scripts. > Hmmm. I'm not sure what exactly debian upgrade script (and IIRC it depends on packages). I wonder if it does fast/smart/immediate. >> Could the replica receive the WAL in some other way - say, from a WAL >> archive? What archive/restore commands you use? > > We have repmgr + barman setup: > >> archive_command = 'test $(psql -Atc "select failed_count from pg_stat_archiver") -gt 10 || rsync --quiet --contimeout=2 --timeout=2 %p BARMAN_HOST::barman/' >> restore_command = 'barman-wal-restore --gzip BARMAN_HOST BARMAN_CLUSTER %f %p' And can you determine how the broken WAL got to the standby? Was it by directly fetching from the primary, or from the barman archive? Is it broken in the archive too? I think one hypothesis is that the standby starts fetching a WAL segment from the primary, and while doing that it gets recycled and overwritten (so the standby gets bogus somewhere half-way through). That should not be possible, of course, but perhaps there's something broken right after a restart? A race condition or something like that? regards -- Tomas Vondra http://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services