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 1nHM3D-0003bu-LB for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Feb 2022 08:40:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nHM3C-0007DJ-D5 for pgsql-hackers@arkaria.postgresql.org; Tue, 08 Feb 2022 08:40:38 +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 1nHM3C-0007D6-2f for pgsql-hackers@lists.postgresql.org; Tue, 08 Feb 2022 08:40:38 +0000 Received: from mail-pl1-x62a.google.com ([2607:f8b0:4864:20::62a]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nHM39-0003Gl-Gr for pgsql-hackers@lists.postgresql.org; Tue, 08 Feb 2022 08:40:37 +0000 Received: by mail-pl1-x62a.google.com with SMTP id x4so5680604plb.4 for ; Tue, 08 Feb 2022 00:40:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:message-id:to:cc:subject:from:in-reply-to:references :user-agent:mime-version:content-transfer-encoding; bh=QzT0ieOmPZRUuW5o7hwYXKd/GALY7GeHgmBn+6hd0dY=; b=eS4LX7Ps1hLc5+qQ0MjYoW1kPptXBAsQK/qqXA1NcoNfKuwULAQGP4GJsuJby2vkJJ F5fX+DEcBd6XVboySlPpz002ZvK0aq4doB6v1Gw6XfrW/qtL49FLPFAbe7enrNeSUYBG y3ZEfkHAy4EOX8Due5NkGty0sOG+Laq6VY2OdYxOqjGYYmKI6y8y5VLKW8MMywFrXHqU iCXI11ksPvehVrb8bduD/FzbUyAVY0itdNpfQnCkJEbGVlRiiX36mAn2CtuU7AVKDgdp 3WP1i6F3UODZta9ESJ3SHxb5Wf3VF/r8hBMg3p5QdhXZn2NSicQZlCwcRgqKbPRxSECI lJUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:to:cc:subject:from:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=QzT0ieOmPZRUuW5o7hwYXKd/GALY7GeHgmBn+6hd0dY=; b=4KorRDe50td+OO4NDXOoEW2KC1snbH2rnWlMHs/p3HLzjALPCMX7vrsTzCIfCv0ojE YOoMZMoDD9H5Dx4c/Omd1+AZvvuuHRa0JDe9A0dhzp3pBQXO73ueO53JM/JjZj0FNRWa V96wphfJz+MlHILFcx5EScI9FdTCvCqEYG/iQMfzMRy8Tud5mggwi1nBEqgNpzBLyj3h IHQCiUFAQ0W9JOK9rQNBnsMReRHgHGzfz6UrkPIHEoox7TLiQy8DccRu+jA4l7IMm7cW d6PnyA4ui6N04xlbDjn/0cJum5T0QP9HKruzpz3uoxNjsuGwNR5ggOAHWf+qwzziUdoB KY1Q== X-Gm-Message-State: AOAM532uhe2jMruvzWa2eHHbvkTom9+ZpT3+XS/ZU6vzX+ScsSgzB7Tt qk6IBBhRVmIbJzWblCD5kLo= X-Google-Smtp-Source: ABdhPJy4qRSBTgPZnLvyBZJujbXiLUTZL+Okkt2sz7UA2RJeVPxbt1JdjY/96/Qseh+EuiNQTyyWAg== X-Received: by 2002:a17:902:e84f:: with SMTP id t15mr3326928plg.102.1644309634308; Tue, 08 Feb 2022 00:40:34 -0800 (PST) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id z11sm1766454pjq.53.2022.02.08.00.40.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 08 Feb 2022 00:40:33 -0800 (PST) Date: Tue, 08 Feb 2022 17:40:29 +0900 (JST) Message-Id: <20220208.174029.1890340465677956009.horikyota.ntt@gmail.com> To: masao.fujii@oss.nttdata.com Cc: bharath.rupireddyforpostgres@gmail.com, nathandbossart@gmail.com, sfrost@snowman.net, bossartn@amazon.com, rjuju123@gmail.com, michael@paquier.xyz, pgsql-hackers@lists.postgresql.org Subject: Re: Add checkpoint and redo LSN to LogCheckpointEnd log message From: Kyotaro Horiguchi In-Reply-To: <20220208.165822.2155503452120234158.horikyota.ntt@gmail.com> References: <20220207.120258.310426179780547983.horikyota.ntt@gmail.com> <20220208.165822.2155503452120234158.horikyota.ntt@gmail.com> User-Agent: Mew version 6.8 on Emacs 26.1 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: Archived-At: Precedence: bulk Mmm.. checkpoint and checkpointer are quite confusing in this context.. At Tue, 08 Feb 2022 16:58:22 +0900 (JST), Kyotaro Horiguchi wrote in > At Mon, 7 Feb 2022 13:51:31 +0900, Fujii Masao wrote in > > > > > > On 2022/02/07 12:02, Kyotaro Horiguchi wrote: > > > - If any later checkpoint/restartpoint has been established, just skip > > > remaining task then return false. (!chkpt_was_latest) > > > (I'm not sure this can happen, though.) > > > - we update control file only when archive recovery is still ongoing. > > > > This comment seems to conflict with what your PoC patch does. Because > > with the patch, ControlFile->checkPoint and > > ControlFile->checkPointCopy seem to be updated even when > > ControlFile->state != DB_IN_ARCHIVE_RECOVERY. > > Ah, yeah, by "update" I meant that "move forward". Sorry for confusing > wording. Please ignore the "that". > > I agree with what your PoC patch does for now. When we're not in > > archive recovery state, checkpoint and REDO locations in pg_control > > should be updated but min recovery point should be reset to invalid > > one (which instruments that subsequent crash recovery should replay > > all available WAL files). > > Yes. All buffers before the last recovery point's end have been > flushed out so the recovery point is valid as a checkpoint. On the > other hand minRecoveryPoint is no longer needed and actually is > ignored at the next crash recovery. We can leave it alone but it is > consistent that it is cleared. > > > > - Otherwise reset minRecoveryPoint then continue. > > > Do you have any thoughts or opinions? > > > > Regarding chkpt_was_latest, whether the state is > > DB_IN_ARCHIVE_RECOVERY or not, if checkpoint and redo locations in > > pg_control are updated, IMO we don't need to skip the "remaining > > tasks". Since those locations are updated and subsequent crash > > recovery will start from that redo location, for example, ISTM that we > > can safely delete old WAL files prior to the redo location as the > > "remaining tasks". Thought? > > If I read you correctly, the PoC works that way. It updates pg_control > if the restart point is latest then performs the remaining cleanup > tasks in that case. Recovery state doesn't affect this process. > > I reexamined about the possibility of concurrent checkpoints. > > Both CreateCheckPoint and CreateRestartPoint are called from > checkpointer loop, shutdown handler of checkpointer and standalone > process. So I can't see a possibility of concurrent checkpoints. > > In the past we had a time when startup process called CreateCheckPoint - directly in the crash recovery case where checkpoint is not running - but since 7ff23c6d27 checkpoint is started before startup process + directly in the crash recovery case where checkpointer is not running + but since 7ff23c6d27 checkpointer is launched before startup process > starts. So I conclude that that cannot happen. > > So the attached takes away the path for the case where the restart > point is overtaken by a concurrent checkpoint. > > Thus.. the attached removes the ambiguity of of the proposed patch > about the LSNs in the restartpoint-ending log message. Thoughts? -- Kyotaro Horiguchi NTT Open Source Software Center