Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1huuZj-0008DL-BU for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Aug 2019 08:12:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1huuZh-0001tA-Uy for pgsql-hackers@arkaria.postgresql.org; Tue, 06 Aug 2019 08:12:05 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1huuZh-0001oP-Hz; Tue, 06 Aug 2019 08:12:05 +0000 Received: from mail-pf1-x441.google.com ([2607:f8b0:4864:20::441]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1huuZd-0000pw-NP; Tue, 06 Aug 2019 08:12:05 +0000 Received: by mail-pf1-x441.google.com with SMTP id q10so41064592pff.9; Tue, 06 Aug 2019 01:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=Zty2qKEjueAsH+jC0K3T0TI19abINVHxMkdFenCbaro=; b=ClTkRz8KhhW+/B6fNFfDvOev4RIdKu+fk66fc/jF0z4orePFELa/eRDAMUuw+t2U7Q sOZreVwQwmHxe5MXH8lSTQA9UrBnbUI6FgkFnAHDIX8/3bOqGJghHmFh3Ne/iRstHlN+ dx/2XPekt9wVJa5i3I1vNQ6/n06ShLojxLD2jOEX7vTBNwcIpjKnku7QGv/hjtgyAa6R dyslbFyDDM3VnKkmiiOt7HMti/bdQd8PoeEhYC9+V9pF+PxrfBlCFfyawLxNywe0QcLp SavoqlIaUvWbdU0Pgsk8/85aVPf+eVy+EhP4tYZMfPTpgSAEhlh5X3L/ZNEDbPxEsMXo zdfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=Zty2qKEjueAsH+jC0K3T0TI19abINVHxMkdFenCbaro=; b=K02dav4veAjwTZCg5cb2yEXObfCu5VXpKuY9EQaT7ro3XhtUA+R4tKTb64BcHkDLpl sca1wD9rJuzi8SVXXEcOElQNrMYveZ0yIc0GacoIfe7Xp5yfxlvSXqd6TafH8RLmEmNo pNCWNWLyxvi1JnjJ4ol6JO7BFkWig+XLDc9WNJVxcBq3wQxcLcgQ40UrfoWGrcvU+c0Q jOZVkrzHTmbnKLW2sSxMGpt3LgjJbODW6AwYMmyIDjY2BxXimKZAbb9QBbX/Z9JP1zNK vgHJMIzJwDy9mXd1JuDK/Qth2IzPcoXDh61Jq++My/xk7NjmsrCv4JlypQpaQl57u8yZ JN6g== X-Gm-Message-State: APjAAAXOJgGPjzs5IqJLeUV5c4WCNrM6oB3U+Vk9XHiBDVsAgeiJIDwi QL46gPbFTk556PDw3I0RD4lBwyPk X-Google-Smtp-Source: APXvYqzh2FwYzDviS2K6Rcyv1USip72hBdKeiFjxMlGDUUKM3ZSh4FsWJC4fjQytNArWa09nyMRr4g== X-Received: by 2002:a63:194f:: with SMTP id 15mr1962252pgz.382.1565079118519; Tue, 06 Aug 2019 01:11:58 -0700 (PDT) Received: from localhost (w204177.dynamic.ppp.asahi-net.or.jp. [121.1.204.177]) by smtp.gmail.com with ESMTPSA id b30sm119151167pfr.117.2019.08.06.01.11.56 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 06 Aug 2019 01:11:58 -0700 (PDT) Date: Tue, 06 Aug 2019 17:11:40 +0900 (Tokyo Standard Time) Message-Id: <20190806.171140.265475235.horikyota.ntt@gmail.com> To: pgsql-hackers@lists.postgresql.org Cc: cyberdemn@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15938: Corrupted WAL segment after crash recovery From: Kyotaro Horiguchi In-Reply-To: <15938-8591df7e95064538@postgresql.org> References: <15938-8591df7e95064538@postgresql.org> User-Agent: Mew version 6.5 on Emacs 22.2 / Mule 5.0 =?iso-2022-jp?B?KBskQjpnGyhCKQ==?= / Meadow-3.01-dev (TSUBO-SUMIRE) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hello. At Thu, 01 Aug 2019 13:52:52 +0000, PG Bug reporting form wrote in <15938-8591df7e95064538@postgresql.org> > The following bug has been logged on the website: > > Bug reference: 15938 > Logged by: Alexander Kukushkin > Email address: cyberdemn@gmail.com > PostgreSQL version: 10.9 > Operating system: Ubuntu 18.04.2 LTS > Description: > > On one of our cluster one of the postgres backend processes was killed by > kernel oom. Although I don't think replication reconnection to crash-recovered master is generally guaranteed, but this seems different. > 2019-08-01 12:41:06.376 UTC,,,22697,,5d42dddb.58a9,4,,2019-08-01 12:40:59 > UTC,,0,LOG,00000,"redo done at B8D/44FFE570",,,,,,,,,"" > 2019-08-01 12:41:06.376 UTC,,,22697,,5d42dddb.58a9,5,,2019-08-01 12:40:59 > UTC,,0,LOG,00000,"last completed transaction was at log time 2019-08-01 > 12:40:54.782747+00",,,,,,,,,"" .. > Unfortunately I can't compare files in the archive and on the primary, > because it was recycled despite usage of replication slots. > pg_replication_slots view reports restart_lsn as B8D/451EB540 (the next > segment). WAL records since 44ffe6d0 (maybe) till 451eb540 are somehow ignored during crash recovery of the master, or lost despite it should have been fsynced out. The only thing I came up for this is the fsync problem but it is fixed in 10.7. But the following wiki description: https://wiki.postgresql.org/wiki/Fsync_Errors > Linux 4.13 and 4.15: fsync() only reports writeback errors that > occurred after you called open() so our schemes for closing and > opening files LRU-style and handing fsync() work off to the > checkpointer process can hide write-back errors; also buffers are > marked clean after errors so even if you opened the file before > the failure, retrying fsync() can falsely report success and the > modified buffer can be thrown away at any time due to memory > pressure. If I read this correctly, after checkpointer failed to fsync while creating of a preallocate file (this is an ERROR, not a PANIC), other processes will never receive fsync error about the file. This scenario is consistent with the fact that it seems that the data loss starts from new segment's beginning (assuming that the original 44ffe6d0 continues to the next segment). Thoughts? > But I can run pg_waldump, and the last record in this file is > CHECKPOINT_SHUTDOWN: > rmgr: XLOG len (rec/tot): 106/ 106, tx: 0, lsn: > B8D/44FFF6D0, prev B8D/44FFE570, desc: CHECKPOINT_SHUTDOWN redo > B8D/44FFF6D0; tli 80; prev tli 80; fpw true; xid 0:42293547; oid 10741249; > multi 1; offset 0; oldest xid 549 in DB 1; oldest multi 1 in DB 1; > oldest/newest commit timestamp xid: 0/0; oldest running xid 0; shutdown > pg_waldump: FATAL: error in WAL record at B8D/44FFF6D0: invalid record > length at B8D/44FFF740: wanted 24, got 0 The shutdown record is written at the end of crash recovery of the master, then replicated. As the result the subsequent bytes are inconsistent with the record. regards. -- Kyotaro Horiguchi NTT Open Source Software Center