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 1nNUe3-0005Fr-MW for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Feb 2022 07:04:03 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nNUe2-0006Zv-2N for pgsql-hackers@arkaria.postgresql.org; Fri, 25 Feb 2022 07:04:02 +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 1nNUe1-0006Zm-Ip for pgsql-hackers@lists.postgresql.org; Fri, 25 Feb 2022 07:04:01 +0000 Received: from mail-pf1-x434.google.com ([2607:f8b0:4864:20::434]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nNUdz-0008Ih-3p for pgsql-hackers@lists.postgresql.org; Fri, 25 Feb 2022 07:04:00 +0000 Received: by mail-pf1-x434.google.com with SMTP id z16so3969323pfh.3 for ; Thu, 24 Feb 2022 23:03:58 -0800 (PST) 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=4/S9yMz9O3Db27/xXwPceZoIQln7HsIIn03a9IIXKN8=; b=WAVqhDAlPGeETFTaEgYzDP2wPfuyzESJdN657rpCeiPB+RThdy10MKkidZhKG0vD2b z+250ueTG1bHWtMfCyckCHk9fQVarLYIzvSddMW/iq+1xZG4r4JjKbDVJMe1frbMUuyV 5kCZ8O4986KZRwLqDDAm551iZB7R2XBwj1hheCyvzs0xfoFB6EphfbGHn6QwL3SrLb4M dBmHLcJCXUlajM9ehKty3a5yDCvCtS3OuYSnQq1nCm37aGRJ0zJKkujNPRtAffuf2ztT 5YWlvIDRyFjj0kZjoU7QOFIcd9i47dwxABB+DMFvEQ+beZnIOverK/K0RgIOFrD3o7qW tG9Q== 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=4/S9yMz9O3Db27/xXwPceZoIQln7HsIIn03a9IIXKN8=; b=rUomuQhrYQNXuylfUa5/x26QJf0kjz+zthYLKSRg1H3+EYxNNfAzr1oTe7PIA/96Qh kT4wSb2wLVU32OqTCW7qpAn2lGiO0xJBotYNtv8LOreZlv8j9vq0PIazh7HOFhlOpxkO JxUCALscuKwuIHGG///Nd2aTd8lJ/FT8DCEzgAEZG3dmXiUBFf6HQsMo3ClwbLYjbCXM U3m4KhFLqGX5ASaAyUFiZH8NZt7oQPtWkh3r6G03F5RAK13aHQ15esqUqgvNk2MsKYLx CgV2lCrhhGqDFsb3YFNnlwB08nM6OyJmLKy7ch4/+uXdKzCu/klic1M7kngs5n4U4f68 uq9w== X-Gm-Message-State: AOAM531MAKrhqSGtm8AxORKKbFGEOk63VCmyJR19ESdIA7z82p/KBUmW Uc01E3ejIrdF6D9rDPJjTcQ= X-Google-Smtp-Source: ABdhPJwXSNrXoMTq0maBWeEE/A98phCSrFZBMmS691OAA74uceO9FZNs+eROfY3O6s4tfEKl1JjVvg== X-Received: by 2002:a05:6a00:88a:b0:4df:f3a9:b246 with SMTP id q10-20020a056a00088a00b004dff3a9b246mr6173732pfj.83.1645772637983; Thu, 24 Feb 2022 23:03:57 -0800 (PST) Received: from jrouhaud (2001-b011-1005-9344-f455-3efb-d76f-9e4c.dynamic-ip6.hinet.net. [2001:b011:1005:9344:f455:3efb:d76f:9e4c]) by smtp.gmail.com with ESMTPSA id 6-20020a17090a030600b001bc62ecad28sm8151511pje.41.2022.02.24.23.03.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Feb 2022 23:03:57 -0800 (PST) Date: Fri, 25 Feb 2022 15:03:52 +0800 From: Julien Rouhaud To: Nitin Jadhav Cc: Matthias van de Meent , Bharath Rupireddy , Bruce Momjian , Tom Lane , Magnus Hagander , PostgreSQL Hackers Subject: Re: Report checkpoint progress with pg_stat_progress_checkpoint (was: Report checkpoint progress in server logs) Message-ID: <20220225070352.fhfwnl5ksfsa4eew@jrouhaud> References: <20220217172724.uhs2v3mgio7y6ga5@jrouhaud> <20220218074351.wgfosjt5lql2vjbr@jrouhaud> <20220219053215.r4wqatln5awklecf@jrouhaud> 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 Hi, On Fri, Feb 25, 2022 at 12:23:27AM +0530, Nitin Jadhav wrote: > > I think the change to ImmediateCheckpointRequested() makes no sense. > > Before this patch, that function merely inquires whether there's an > > immediate checkpoint queued. After this patch, it ... changes a > > progress-reporting flag? I think it would make more sense to make the > > progress-report flag change in whatever is the place that *requests* an > > immediate checkpoint rather than here. > > > > > diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c > > > +ImmediateCheckpointRequested(int flags) > > > if (cps->ckpt_flags & CHECKPOINT_IMMEDIATE) > > > + { > > > + updated_flags |= CHECKPOINT_IMMEDIATE; > > > > I don't think that these changes are expected behaviour. Under in this > > condition; the currently running checkpoint is still not 'immediate', > > but it is going to hurry up for a new, actually immediate checkpoint. > > Those are different kinds of checkpoint handling; and I don't think > > you should modify the reported flags to show that we're going to do > > stuff faster than usual. Maybe maintiain a seperate 'upcoming > > checkpoint flags' field instead? > > Thank you Alvaro and Matthias for your views. I understand your point > of not updating the progress-report flag here as it just checks > whether the CHECKPOINT_IMMEDIATE is set or not and takes an action > based on that but it doesn't change the checkpoint flags. I will > modify the code but I am a bit confused here. As per Alvaro, we need > to make the progress-report flag change in whatever is the place that > *requests* an immediate checkpoint. I feel this gives information > about the upcoming checkpoint not the current one. So updating here > provides wrong details in the view. The flags available during > CreateCheckPoint() will remain same for the entire checkpoint > operation and we should show the same information in the view till it > completes. I'm not sure what Matthias meant, but as far as I know there's no fundamental difference between checkpoint with and without the CHECKPOINT_IMMEDIATE flag, and there's also no scheduling for multiple checkpoints. Yes, the flags will remain the same but checkpoint.c will test both the passed flags and the shmem flags to see whether a delay should be added or not, which is the only difference in checkpoint processing for this flag. See the call to ImmediateCheckpointRequested() which will look at the value in shmem: /* * Perform the usual duties and take a nap, unless we're behind schedule, * in which case we just try to catch up as quickly as possible. */ if (!(flags & CHECKPOINT_IMMEDIATE) && !ShutdownRequestPending && !ImmediateCheckpointRequested() && IsCheckpointOnSchedule(progress)) [...]