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 1njm6t-00023z-Ps for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Apr 2022 18:09:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1njm6s-0003Ia-N2 for pgsql-hackers@arkaria.postgresql.org; Wed, 27 Apr 2022 18:09:54 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1njm6s-0003Hp-BC for pgsql-hackers@lists.postgresql.org; Wed, 27 Apr 2022 18:09:54 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1njm6o-0000ct-An for pgsql-hackers@lists.postgresql.org; Wed, 27 Apr 2022 18:09:53 +0000 Received: by mail-pg1-x530.google.com with SMTP id i62so2057567pgd.6 for ; Wed, 27 Apr 2022 11:09:49 -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=RZAFrWUAlHAnYWXgtb6VUcfy6gD0QluHZckhIFQFOf4=; b=fYd30amE1G9VVd0n6plPL1Oln1jJWPUsf24bdqarWBn9EtlBRVl5FfXTvMjiEQRKtU 7m5HHgJ2seehShnP4BUao5qfAhA+MRdRB5+4N4rAqtD+puk1o2tN/LTT6CXOR0zWrZ53 TkCpvrw7F1psjdq8u1wMhxIh9zx6CrvF8hZscvrzXTtCK3X4MZyLjybDVqYYv+uhS995 pA3YcklkJsBJBolmgWoLNKbi238FMKUXvzTvbhyGKlOijwKv6DsO2msKHqqFAUsjONZ9 9xpUMVCNEhRaF23xfUzT4AdBMz49LHlmX5oJAlLptJhHGMRRqYYiqMgOLPrGJ3eXsxjn Ujag== 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=RZAFrWUAlHAnYWXgtb6VUcfy6gD0QluHZckhIFQFOf4=; b=UwJ9o94/2EWsy7YyRaQNL76+cJWdyfc4HcZ4M8BSbfybCz16wErm6oHuHV6PyV4qKK at2k17JzStYHr0+E4pSbuPuATXAqEhAjRTl7Tdaz/A9JQ3IbvKW2PB/+m+JvM1ZpQD0k WoGGrfv/Kz10DalTOuzPvxYXT1GBeaXVVnAokS18/1SvjqrVbVOa1Q0/Fus/WmFPIyMg l9EttECouBgvamaYm7D/22w9x329xrGzhKUd1soqqN5pAcpnvfGK3Y9M5bge5EAoIeQ3 3SuNWMrokfSwH/Jo60Jt18zpCD0c6/CWOOHpsK7WHL7pA9G3nbB/d6pN/17KiffMgkn7 L0Ig== X-Gm-Message-State: AOAM5305ps4wcHTYhFdbG6LSlRZliYKskuvkdJzkMSFKUw6T3i9j8s8i NoE1V6NpdZSxd5iZ1eqPMGM= X-Google-Smtp-Source: ABdhPJwVcMFWb3PUbJu+yWA5Z4/yDDhPVURYNqZg5w7t2k2AC4IQzWZurxjs8HoSmJo9EVlZ39oCZg== X-Received: by 2002:a63:ec50:0:b0:39d:2d53:76e7 with SMTP id r16-20020a63ec50000000b0039d2d5376e7mr24736445pgj.338.1651082988307; Wed, 27 Apr 2022 11:09:48 -0700 (PDT) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id e9-20020a17090ab38900b001cd4989fecdsm7835400pjr.25.2022.04.27.11.09.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 11:09:47 -0700 (PDT) Date: Wed, 27 Apr 2022 11:09:45 -0700 From: Nathan Bossart To: Michael Paquier Cc: Kyotaro Horiguchi , pgsql-hackers@lists.postgresql.org, masao.fujii@oss.nttdata.com Subject: Re: Possible corruption by CreateRestartPoint at promotion Message-ID: <20220427180945.GA3222843@nathanxps13> References: <20220316.102444.2193181487576617583.horikyota.ntt@gmail.com> <20220426183349.GA3002960@nathanxps13> <20220427.104353.691219597727808197.horikyota.ntt@gmail.com> <20220427032609.GA3220948@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 27, 2022 at 02:16:01PM +0900, Michael Paquier wrote: > On Tue, Apr 26, 2022 at 08:26:09PM -0700, Nathan Bossart wrote: >> On Wed, Apr 27, 2022 at 10:43:53AM +0900, Kyotaro Horiguchi wrote: >>> + 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. > > Anyway, that would be the work of the end-of-recovery checkpoint > requested at the end of StartupXLOG() once a promotion happens or of > the checkpoint requested by PerformRecoveryXLogAction() in the second > case, no? So, I don't quite see why we need to update > minRecoveryPoint and minRecoveryPointTLI in the control file here, as > much as this does not have to be part of the end-of-recovery code > that switches the control file to DB_IN_PRODUCTION. +1. We probably don't need to reset minRecoveryPoint here. > - if (ControlFile->state == DB_IN_ARCHIVE_RECOVERY && > - ControlFile->checkPointCopy.redo < lastCheckPoint.redo) > - { > 7ff23c6 has removed the last call to CreateCheckpoint() outside the > checkpointer, meaning that there is one less concurrent race to worry > about, but I have to admit that this change, to update the control > file's checkPoint and checkPointCopy even if we don't check after > ControlFile->checkPointCopy.redo < lastCheckPoint.redo would make the > code less robust in ~14. So I am questioning whether a backpatch > is actually worth the risk here. IMO we should still check this before updating ControlFile to be safe. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com