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 1jQVRn-0003Qb-LB for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Apr 2020 12:22:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jQVRk-0007P6-Sv for pgsql-bugs@arkaria.postgresql.org; Mon, 20 Apr 2020 12:22:44 +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 1jQVRk-0007Oz-5h for pgsql-bugs@lists.postgresql.org; Mon, 20 Apr 2020 12:22:44 +0000 Received: from mail.dalibo.com ([212.85.157.172]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jQVRh-0000Az-3f for pgsql-bugs@lists.postgresql.org; Mon, 20 Apr 2020 12:22:42 +0000 Received: from firost (larco.ioguix.net [82.66.0.6]) by mail.dalibo.com (Postfix) with ESMTPSA id 787A02060D; Mon, 20 Apr 2020 14:22:36 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=dalibo.com; s=a; t=1587385356; bh=YLAPfN0kU251z81pbZ/Egl/SbPcgSRuzG2IyqHeqDTg=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=RW914GI+8hhfJjuTbmhXQbwMfcHBaEkTqh/vTrhlqWCMPR1JBmqUAOzfA+SGotfJf EysJqs4rVWxjK97UxnMJoNcKhlli6Q42uNBstynP8yk5cR4C3rmVpcHYsNilCnABa7 itbhYbxB0xxhQZ6dnnNmnSFfmimlZrWCmsXiBCSc= Date: Mon, 20 Apr 2020 14:22:35 +0200 From: Jehan-Guillaume de Rorthais To: Michael Paquier Cc: Kyotaro Horiguchi , masao.fujii@oss.nttdata.com, pgsql-bugs@lists.postgresql.org Subject: Re: [BUG] non archived WAL removed during production crash recovery Message-ID: <20200420142235.1536a73b@firost> In-Reply-To: <20200420073444.GA77439@paquier.xyz> References: <20200417065043.GC350229@paquier.xyz> <20200417153304.01a226cc@firost> <20200418092611.GD350229@paquier.xyz> <20200420.160231.719176619682386260.horikyota.ntt@gmail.com> <20200420073444.GA77439@paquier.xyz> Organization: Dalibo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Mon, 20 Apr 2020 16:34:44 +0900 Michael Paquier wrote: [...] > > By the way I noticed that RecoveryState is exactly a subset of > > DBState. And changes of SharedRecoveryState happens side-by-side with > > ControlFileData->state in most places. Coundn't we just usee > > ControlFile->state instead of SharedRecoveryState? >=20 > I actually found confusing to use the same thing, because then the > reader would thing that SharedRecoveryState could be set to more > values but we don't want that. I thought about this while studying various possible fix.=20 https://www.postgresql.org/message-id/flat/20200401181735.11100908%40firost= #6192afba4e4549b8d9bac03168bad46b The problem is that we would have to read the controldata file each time we wonder if a segment should be archived/removed. Moreover, the controldata file might not be in sync quickly enough with the real state for some other code path or futur needs. [...] > Attached is an updated patch, where I tweaked more comments. >=20 > Jehan-Guillaume, who is your colleague who found originally about this > problem? We should credit him in the commit message. Indeed, Beno=C3=AEt Lobr=C3=A9au reported this behavior to me. Regards,