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 1nKkZ9-0007qp-4R for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Feb 2022 17:27:39 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKkZ6-0008DE-MW for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Feb 2022 17:27:36 +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 1nKkZ6-0008CV-Bk for pgsql-hackers@lists.postgresql.org; Thu, 17 Feb 2022 17:27:36 +0000 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nKkZ1-0003XO-TO for pgsql-hackers@lists.postgresql.org; Thu, 17 Feb 2022 17:27:35 +0000 Received: by mail-pg1-x529.google.com with SMTP id f8so5606900pgc.8 for ; Thu, 17 Feb 2022 09:27:31 -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=Qi4vSUg7ec9X+g9xO55FZfcdqJjfCv1q20Gw8AqJx9w=; b=li6r5tK+gC23fgI9HNAQKOOjCcfGFaMDikaQBGH25E9ioA8tuABGiJeiW/SSdG54vV ZSfEUjtfjfxMYj2NCu47ew7PiOicqLLcuwEEu0Y901WGIerBghgRl520wezqZWQSMQvZ E6uClQ8ApRO6IeMBSPPy8Teuyz30pfRQoSRRi2SFScDn9dB+jgBd9fqju3E04s0boYF/ qQ4QAjXMQy5KTm5OVPx1dhpNy00zCIgZf6VXgGDTvkHruxVwf4q5Mj6NbT9ciSqzivV7 iVGVxVgM8/pDZkJo9/GDY80OYXA8WzC+pOoJKBxdIMYM7LEqau4kgsVJqbXfKriyMXVg 7vHQ== 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=Qi4vSUg7ec9X+g9xO55FZfcdqJjfCv1q20Gw8AqJx9w=; b=nEFxQDMZ7ZrkrJAKUPUKhmfPRG7I/nlG9w+sDJPFSwe0As7QbBISnY0BmO0jtilYXE UaAuFoh+QRGSNphXOzZ72yRvyEhz0TD4H4EtFT2bleetvZO3oUXzaEcnHkSY7KQlasnm 2vEnxEz9vXzM4LXxR4knHrwe8+HlXguiDdgEJEe8s6sdRK1DQw+DTZJhoi5JCnXqKt2B 4fmQqojexfNlXE5emd99MXKIliX6gFOC5LukQ2A1DclWaabh6D3mwHCANGSG5tIvsLpZ 4ofhfGfZ6TMnqfwnWbUXiFXKdGmUiuuwR8WM8dw4lgZSUt8cnKoVrxJg0/kNGYkKh2Lv z2ZQ== X-Gm-Message-State: AOAM532BqwOWXoZcYFGFf8msjd2wnny2fiyvYuRG3UX6PpY4Zpxi1Lyo fv1bLPxuH2A3z9MTSWbiZ9U= X-Google-Smtp-Source: ABdhPJyhWeqWsluEFKp+s+ehjMJF92YAZju8wWRVtkBOdo40OwRyZWF/54YMLMjILK5hVuG8+/8jnQ== X-Received: by 2002:a63:571d:0:b0:372:8da2:10e1 with SMTP id l29-20020a63571d000000b003728da210e1mr3199078pgb.271.1645118850682; Thu, 17 Feb 2022 09:27:30 -0800 (PST) Received: from jrouhaud (2001-b011-1005-1e7d-a4b8-999b-acec-a473.dynamic-ip6.hinet.net. [2001:b011:1005:1e7d:a4b8:999b:acec:a473]) by smtp.gmail.com with ESMTPSA id v2sm2268007pjt.55.2022.02.17.09.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 09:27:30 -0800 (PST) Date: Fri, 18 Feb 2022 01:27:24 +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: <20220217172724.uhs2v3mgio7y6ga5@jrouhaud> References: <2031846.1640792459@sss.pgh.pa.us> <20220217110515.zssjnez4lq2lmrdq@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 Thu, Feb 17, 2022 at 10:39:02PM +0530, Nitin Jadhav wrote: > > > Thank you for sharing the information. 'triggering backend PID' (int) > > > - can be stored without any problem. > > > > There can be multiple processes triggering a checkpoint, or at least wanting it > > to happen or happen faster. > > Yes. There can be multiple processes but there will be one checkpoint > operation at a time. So the backend PID corresponds to the current > checkpoint operation. Let me know if I am missing something. If there's a checkpoint timed triggered and then someone calls pg_start_backup() which then wait for the end of the current checkpoint (possibly after changing the flags), I think the view should reflect that in some way. Maybe storing an array of (pid, flags) is too much, but at least a counter with the number of processes actively waiting for the end of the checkpoint. > > > 'checkpoint or restartpoint?' > > > > Do you actually need to store that? Can't it be inferred from > > pg_is_in_recovery()? > > AFAIK we cannot use pg_is_in_recovery() to predict whether it is a > checkpoint or restartpoint because if the system exits from recovery > mode during restartpoint then any query to pg_stat_progress_checkpoint > view will return it as a checkpoint which is ideally not correct. Please > correct me if I am wrong. Recovery ends with an end-of-recovery checkpoint that has to finish before the promotion can happen, so I don't think that a restart can still be in progress if pg_is_in_recovery() returns false.