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 1njYJm-0003sm-F1 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Apr 2022 03:26:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1njYJk-0005wo-RX for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Apr 2022 03:26:16 +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 1njYJk-0005wf-GG for pgsql-hackers@lists.postgresql.org; Wed, 27 Apr 2022 03:26:16 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1njYJh-0005G0-DW for pgsql-hackers@lists.postgresql.org; Wed, 27 Apr 2022 03:26:15 +0000 Received: by mail-pj1-x102d.google.com with SMTP id cu23-20020a17090afa9700b001d98d8e53b7so3194421pjb.0 for ; Tue, 26 Apr 2022 20:26:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=FXtmLKFA4jOw+x0xtEarSvdEKBHH0vBVz5E5+AQhQMo=; b=Opfftun78JLwR+rPLjlDLztdo9rwuFmGQ9PcFiz4sL7rBGhnuRPTIoPaw1FyuQN2KB BzgXI2dun1Uc4KM14uMujLmL0OVunz0qTEPLnTh9NDCd4LXW+sFLNWTjST4jzM7PiALM t7m8rokZLW7YSuMcJfe5bSYyAuMFaEXqBnrHZ4ZhZ0zdd9r1+gBqU9j+lM3+ibyT4rUr OSTQP1bv0WhFYgPdHCnzlq41U89NDkaRp5KicUyK51HIWTEy+1SG4ULj5NlDQNGpiRdU Vi4hyi3t+gev0ctb70UG78g417P1XFBP8dZw3w7LEHPUWD2itUeDoUYRi1IfKR4tTqjN tvuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=FXtmLKFA4jOw+x0xtEarSvdEKBHH0vBVz5E5+AQhQMo=; b=8FXeDKd37cRIW32CRKMY1JqT7AM0L/RF+2W5PF+5sSfWG+cLFCUQ5OowlEKMAgVlpT SkHWnfYagN4e/xXu2R2/MoSscpRJTiQTpBytummc/axnBpnpWuw2HxMIX2lffFKKcAqv BltmqHnmlwHIRnQXMvwb3Pf+aKXTH3MbulgVverDPJ7FJUCh6o0Gxvt2/5iNIoy7ZVpb rhQTob3CsZhGxVfbXwTPQPn91WRbjRweWv7OUmblsBzq31KRW8PpsQrj9b9iUNrfhBdz C1c8/1l8fU55vULB5LPSwvkQ5Blw8Hxv5IptEGwKiolzD4qavAeAWOrgOtNo+i/piduB 0Ucw== X-Gm-Message-State: AOAM533advNg1owwN0ooOMPUf6XtsAaAGtBLTzkVDlpK/1WfjRuSzZNk cidgkl3vxh7tA3GGhm23MNE= X-Google-Smtp-Source: ABdhPJyMti8JLGp+KOgkztm4SdLSPJdDWPM2X/v3rmU6cL1c3u26EuL/KQNv6hgQBOl/QLjqiPxMSw== X-Received: by 2002:a17:90a:4f0b:b0:1d9:acbd:1204 with SMTP id p11-20020a17090a4f0b00b001d9acbd1204mr7604200pjh.201.1651029972373; Tue, 26 Apr 2022 20:26:12 -0700 (PDT) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id s22-20020a17090a5d1600b001d954837197sm4787474pji.22.2022.04.26.20.26.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 20:26:11 -0700 (PDT) Date: Tue, 26 Apr 2022 20:26:09 -0700 From: Nathan Bossart To: Kyotaro Horiguchi Cc: pgsql-hackers@lists.postgresql.org, masao.fujii@oss.nttdata.com Subject: Re: Possible corruption by CreateRestartPoint at promotion Message-ID: <20220427032609.GA3220948@nathanxps13> References: <20220316.102444.2193181487576617583.horikyota.ntt@gmail.com> <20220426183349.GA3002960@nathanxps13> <20220427.104353.691219597727808197.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220427.104353.691219597727808197.horikyota.ntt@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 27, 2022 at 10:43:53AM +0900, Kyotaro Horiguchi wrote: > At Tue, 26 Apr 2022 11:33:49 -0700, Nathan Bossart wrote in >> I suspect we'll start seeing this problem more often once end-of-recovery >> checkpoints are removed [0]. Would you mind creating a commitfest entry >> for this thread? I didn't see one. > > I'm not sure the patch makes any change here, because restart points > don't run while crash recovery, since no checkpoint records seen > during a crash recovery. Anyway the patch doesn't apply anymore so > rebased, but only the one for master for the lack of time for now. Thanks for the new patch! Yeah, it wouldn't affect crash recovery, but IIUC Robert's patch also applies to archive recovery. > + /* Update pg_control */ > + LWLockAcquire(ControlFileLock, LW_EXCLUSIVE); > + > /* > * Remember the prior checkpoint's redo ptr for > * UpdateCheckPointDistanceEstimate() > */ > PriorRedoPtr = ControlFile->checkPointCopy.redo; nitpick: Why move the LWLockAcquire() all the way up here? > + Assert (PriorRedoPtr < RedoRecPtr); I think this could use a short explanation. > + * Ensure minRecoveryPoint is past the checkpoint record while archive > + * recovery is still ongoing. Normally, this will have happened already > + * while writing out dirty buffers, but not necessarily - e.g. because no > + * buffers were dirtied. We do this because a non-exclusive base backup > + * uses minRecoveryPoint to determine which WAL files must be included in > + * the backup, and the file (or files) containing the checkpoint record > + * must be included, at a minimum. Note that for an ordinary restart of > + * recovery there's no value in having the minimum recovery point any > + * earlier than this anyway, because redo will begin just after the > + * checkpoint record. nitpick: Since exclusive backup mode is now removed, we don't need to specify that the base backup is non-exclusive. > + /* > + * Aarchive recovery has ended. Crash recovery ever after should > + * always recover to the end of WAL > + */ > + ControlFile->minRecoveryPoint = InvalidXLogRecPtr; > + ControlFile->minRecoveryPointTLI = 0; > + > + /* also update local copy */ > + LocalMinRecoveryPoint = InvalidXLogRecPtr; > + LocalMinRecoveryPointTLI = 0; Should this be handled by the code that changes the control file state to DB_IN_PRODUCTION instead? It looks like this is ordinarily done in the next checkpoint. It's not clear to me why it is done this way. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com