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 1nNJFn-0000Va-BO for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Feb 2022 18:54:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nNJFl-0006B4-H5 for pgsql-hackers@arkaria.postgresql.org; Thu, 24 Feb 2022 18:54:13 +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 1nNJFl-0006Av-5E for pgsql-hackers@lists.postgresql.org; Thu, 24 Feb 2022 18:54:13 +0000 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nNJFe-0003lT-JQ for pgsql-hackers@lists.postgresql.org; Thu, 24 Feb 2022 18:54:12 +0000 Received: by mail-ej1-x633.google.com with SMTP id bg10so6325227ejb.4 for ; Thu, 24 Feb 2022 10:54:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eNGQDTYtzYX+da+RXNiA3pUfO5tjLdDVhU22FuERhOU=; b=nMTTLputTGfht/o+3wqiUo/2iX7mmPi/mRVFA3wVRai4lmSH4vK+7NE5T0P3B3a1+3 7I1iayV1QbL+IqMQTAzxganRQ2Yzh6Zv8cTDvzqWwkb6mVCeH+9VsFEm+QpqB8UKlRS4 JGCxk4EMy+myw6MtL6NcOSZiadKbXs4HfH6TzsFYRx8UODE3WRqX1RU/Lgj3y27Q7eNz ip2iMhMWGLW4grHSG0sisufrHS5IYyUCf3wmP/VZcmSUToMRBlSjK1/K6XcCqA55b6ut fzf2y53Yz1BZbJWkLAR8VHcyBfzjYX5NM3Q5RLfLfX+lM6n7vXWFMDzoZOhUJirTu8Ls rHTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eNGQDTYtzYX+da+RXNiA3pUfO5tjLdDVhU22FuERhOU=; b=eZiSLdX+ST2PFLXTrhBCWH29xQInYMTfQRwunXUhkPmIBbJ12z3/PEwQQU4r5uv3KU 1JNM1s9uG6jBk+90zyCCxzCApff6ZdcYJ373/FzLC4X/vnJqRe2Y8/deMuzC1VFuKrYZ 3Haj9w4SuSxEM921XIkpoCCismEpk6ETUnmuinIJhP1DlSxwdd4z5v2akibTHYZgvbc6 ZPuNWla+gxyFLIqEi5uaw5VjGYsRHvp/0PC6gFF+Gl27HOxA8nlr8WEHHDUD5rs8dG9F 9K7Hm9McrVilMJRA5AM1jSUQtmxlMQPlVDjSUcXbkwWZV9bSiNbYAjzgLLsVB3jt94RI H7xA== X-Gm-Message-State: AOAM530/cpvZjTucVybiUJdpxGgu5agYod5oFKFkXbliYmL5qn1f3Jzi yLVqV3I1mDnRR2VO5IjcfzpShEds5ujXGcCgyxs= X-Google-Smtp-Source: ABdhPJyYrTB8FDcsDySp0z/4AZl5VEBgmskTrWk0js2r9iiOBd0viN26CQrAjVQvLoRtDB81JrGgMJzGD4k7xaw5+3A= X-Received: by 2002:a17:906:1be1:b0:6ce:b0a8:17d with SMTP id t1-20020a1709061be100b006ceb0a8017dmr3310300ejg.413.1645728845522; Thu, 24 Feb 2022 10:54:05 -0800 (PST) MIME-Version: 1.0 References: <20220217110515.zssjnez4lq2lmrdq@jrouhaud> <20220217172724.uhs2v3mgio7y6ga5@jrouhaud> <20220218074351.wgfosjt5lql2vjbr@jrouhaud> <20220219053215.r4wqatln5awklecf@jrouhaud> In-Reply-To: From: Nitin Jadhav Date: Fri, 25 Feb 2022 00:23:27 +0530 Message-ID: Subject: Re: Report checkpoint progress with pg_stat_progress_checkpoint (was: Report checkpoint progress in server logs) To: Matthias van de Meent Cc: Julien Rouhaud , Bharath Rupireddy , Bruce Momjian , Tom Lane , Magnus Hagander , PostgreSQL Hackers Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > 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. So just removing the above piece of code (modified in ImmediateCheckpointRequested()) in the patch will make it correct. My opinion about maintaining a separate field to show upcoming checkpoint flags is it makes the view complex. Please share your thoughts. Thanks & Regards, On Thu, Feb 24, 2022 at 10:45 PM Matthias van de Meent wrote: > > On Wed, 23 Feb 2022 at 14:28, Nitin Jadhav > wrote: > > > > Sharing the v2 patch. Kindly have a look and share your comments. > > Thanks for updating. > > > diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml > > With the new pg_stat_progress_checkpoint, you should also add a > backreference to this progress reporting in the CHECKPOINT sql command > documentation located in checkpoint.sgml, and maybe in wal.sgml and/or > backup.sgml too. See e.g. cluster.sgml around line 195 for an example. > > > 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? > > > diff --git a/src/backend/catalog/system_views.sql b/src/backend/catalog/system_views.sql > > + ( SELECT '0/0'::pg_lsn + > > + ((CASE > > + WHEN stat.lsn_int64 < 0 THEN pow(2::numeric, 64::numeric)::numeric > > + ELSE 0::numeric > > + END) + > > + stat.lsn_int64::numeric) > > + FROM (SELECT s.param3::bigint) AS stat(lsn_int64) > > + ) AS start_lsn, > > My LSN select statement was an example that could be run directly in > psql; the so you didn't have to embed the SELECT into the view query. > The following should be sufficient (and save the planner a few cycles > otherwise spent in inlining): > > + ('0/0'::pg_lsn + > + ((CASE > + WHEN s.param3 < 0 THEN pow(2::numeric, > 64::numeric)::numeric > + ELSE 0::numeric > + END) + > + s.param3::numeric) > + ) AS start_lsn, > > > > diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c > > +checkpoint_progress_start(int flags) > > [...] > > +checkpoint_progress_update_param(int index, int64 val) > > [...] > > +checkpoint_progress_end(void) > > +{ > > + /* In bootstrap mode, we don't actually record anything. */ > > + if (IsBootstrapProcessingMode()) > > + return; > > Disabling pgstat progress reporting when in bootstrap processing mode > / startup/end-of-recovery makes very little sense (see upthread) and > should be removed, regardless of whether seperate functions stay. > > > diff --git a/src/include/commands/progress.h b/src/include/commands/progress.h > > +#define PROGRESS_CHECKPOINT_PHASE_INIT 0 > > Generally, enum-like values in a stat_progress field are 1-indexed, to > differentiate between empty/uninitialized (0) and states that have > been set by the progress reporting infrastructure. > > > > Kind regards, > > Matthias van de Meent