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 1nOLGC-00085G-Qd for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Feb 2022 15:14:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nOLGB-0005AR-Kx for pgsql-hackers@arkaria.postgresql.org; Sun, 27 Feb 2022 15:14:55 +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 1nOLGB-0005AI-9W for pgsql-hackers@lists.postgresql.org; Sun, 27 Feb 2022 15:14:55 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nOLG9-0001lr-5T for pgsql-hackers@lists.postgresql.org; Sun, 27 Feb 2022 15:14:54 +0000 Received: by mail-pf1-x436.google.com with SMTP id p8so8862197pfh.8 for ; Sun, 27 Feb 2022 07:14:52 -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=QuttsF+Wn/OV9mTEoesL+leiu52JbHJk7Ks8S5OXp2Y=; b=Crh4gXNKKV0Oov6zoEAEHF/SM6EcC6RLtP1HZtOyWa4t/btcl9/bzv52ndi6c98rTA dp71GtZZIZuO6+SkYyR6hEXVUMq02H+a8X4mfR8wi0Ikf7Q2HHTJfi3tbQDdoL0dy8J0 K+aV+QbdNWPK9WfdIBru7EwSDYnCYpym00neVNj5A3D8miV3bmaRWOMLj8zysFDBjYqB vuZGGVTXhN+w+pp8sFLKYYpX+nDY/IXXnw7Y4nfExziYCpQdOFcaMdFXSmnmIIEjrizY SJD77tSqtL6uGxYP315sZkrzbOsT2xOTdzyNJvvA+53B289XA0m8Q4WCEIa3zqgFWmnU k9CQ== 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=QuttsF+Wn/OV9mTEoesL+leiu52JbHJk7Ks8S5OXp2Y=; b=niKF1bpeHHoV5/Du2TAfwsa2EKDJyAesWGjcC+lozmFK1ljUkR6tM49HYD7XK/yRF0 ckwfuZjtC8m6CDsqxbpyPxw/8v0OKGDli5qlIjHGdzL2ng1VHSX7cK/E5EVfK1a3kh4T O5C28nSlBBoOOXI4L+HvS+LAax2k0uQ8Eyg92zauA7Bd9XkhixPE1I9vWhlDtHd1WGSx +G992XbUp/g3VLNv6fR98uavffWvmw2/DYhExHx9myaXtU0Igp/BhriJ23f5qiRMYZUt HUuCKzSpAIzgcI7WeMQMT8/hM+j/kWTlF4q1Wl5I8dDbuwk3wpqC7yg8bsXp5eIeccVm mtuA== X-Gm-Message-State: AOAM530+8OZbsSlfzCYqkzy5fceHcyzZYDtktFbEgxoVU62tqWT2vEmA 98D1QCiwgssNtNYhOzuttrXk2YXGlxsLfYefluo0KrmsCZo= X-Google-Smtp-Source: ABdhPJzCyZzdDFoW1F2LW0ZLMYWoSVlOvUnrLGRVfG2JuHzzHmDojbLNq2oPdvY5L2HwRmNQBeC8ng1KjXZkY7y3j3U= X-Received: by 2002:a63:6782:0:b0:342:7457:69a4 with SMTP id b124-20020a636782000000b00342745769a4mr13664348pgc.410.1645974890888; Sun, 27 Feb 2022 07:14:50 -0800 (PST) MIME-Version: 1.0 References: <20220217110515.zssjnez4lq2lmrdq@jrouhaud> <20220217172724.uhs2v3mgio7y6ga5@jrouhaud> <20220218074351.wgfosjt5lql2vjbr@jrouhaud> <20220219053215.r4wqatln5awklecf@jrouhaud> In-Reply-To: From: Bharath Rupireddy Date: Sun, 27 Feb 2022 20:44:39 +0530 Message-ID: Subject: Re: Report checkpoint progress with pg_stat_progress_checkpoint (was: Report checkpoint progress in server logs) To: Nitin Jadhav Cc: Ashutosh Sharma , Julien Rouhaud , Matthias van de Meent , 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 On Fri, Feb 25, 2022 at 8:38 PM Nitin Jadhav wrote: Had a quick look over the v3 patch. I'm not sure if it's the best way to have pg_stat_get_progress_checkpoint_type, pg_stat_get_progress_checkpoint_kind and pg_stat_get_progress_checkpoint_start_time just for printing info in readable format in pg_stat_progress_checkpoint. I don't think these functions will ever be useful for the users. 1) Can't we use pg_is_in_recovery to determine if it's a restartpoint or checkpoint instead of having a new function pg_stat_get_progress_checkpoint_type? 2) Can't we just have these checks inside CASE-WHEN-THEN-ELSE blocks directly instead of new function pg_stat_get_progress_checkpoint_kind? + snprintf(ckpt_kind, MAXPGPATH, "%s%s%s%s%s%s%s%s%s", + (flags == 0) ? "unknown" : "", + (flags & CHECKPOINT_IS_SHUTDOWN) ? "shutdown " : "", + (flags & CHECKPOINT_END_OF_RECOVERY) ? "end-of-recovery " : "", + (flags & CHECKPOINT_IMMEDIATE) ? "immediate " : "", + (flags & CHECKPOINT_FORCE) ? "force " : "", + (flags & CHECKPOINT_WAIT) ? "wait " : "", + (flags & CHECKPOINT_CAUSE_XLOG) ? "wal " : "", + (flags & CHECKPOINT_CAUSE_TIME) ? "time " : "", + (flags & CHECKPOINT_FLUSH_ALL) ? "flush-all" : ""); 3) Why do we need this extra calculation for start_lsn? Do you ever see a negative LSN or something here? + ('0/0'::pg_lsn + ( + CASE + WHEN (s.param3 < 0) THEN pow((2)::numeric, (64)::numeric) + ELSE (0)::numeric + END + (s.param3)::numeric)) AS start_lsn, 4) Can't you use timestamptz_in(to_char(s.param4)) instead of pg_stat_get_progress_checkpoint_start_time? I don't quite understand the reasoning for having this function and it's named as *checkpoint* when it doesn't do anything specific to the checkpoint at all? Having 3 unnecessary functions that aren't useful to the users at all in proc.dat will simply eatup the function oids IMO. Hence, I suggest let's try to do without extra functions. Regards, Bharath Rupireddy.