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 1nKxvv-0000JH-DD for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Feb 2022 07:44: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 1nKxvt-0004nc-He for pgsql-hackers@arkaria.postgresql.org; Fri, 18 Feb 2022 07:44:01 +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 1nKxvt-0004nS-5y for pgsql-hackers@lists.postgresql.org; Fri, 18 Feb 2022 07:44:01 +0000 Received: from mail-pj1-x102d.google.com ([2607:f8b0:4864:20::102d]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nKxvo-0001nq-UV for pgsql-hackers@lists.postgresql.org; Fri, 18 Feb 2022 07:43:59 +0000 Received: by mail-pj1-x102d.google.com with SMTP id d9-20020a17090a498900b001b8bb1d00e7so7754199pjh.3 for ; Thu, 17 Feb 2022 23:43:56 -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=Wopr5WaXYM11lqTKHoNpL51zEwcbHSBk3TKzhhpug9s=; b=kxPc85Dp/XkkbkMBP86xWHV29N+574WZ8e6kYLnhwW/MRy9horiL3GlqITMd/X+ws0 1owJVe+Nz5GV8x1SnwTENGlwH7qad1m9DK6I1/2TxValoKwhnMWuVWq/KluIhZvwyfdW FC868V0/Z7Kz+8du3Mslu+Wh8ce9/8d8pK7M0NVgoJkzM4RWk8gDQRT78lLtvC9Sldef LZDFN7X1217x+J7dZLLi1CLmIaJ1ooSKwTWOntsa3xKD/O0yUnUSnWVKE3XVombJLy+1 om7g6AA8S/PPCJ5V18FLqe1wBA9auTaTPMNXD7nGBSyiudPKb41LszH5legeTVxWvEER N7ow== 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=Wopr5WaXYM11lqTKHoNpL51zEwcbHSBk3TKzhhpug9s=; b=OhoeOPzXygUkUDkSs+Hf+GuWkpn3MaAZ5mQDvqGRzlQmWorXJxjsIJAziga+0zulFn 8bLyi+MAigm9aEvbQDmOT9eHtNvpdDHBzspNG45byDo+RStFXeQAVc58A80wb7G49tnf aiAGGJ15g3RdgeU7ckwW1AkHRXjRY5hBtypIZ8gTOX11VtxFvsyl0MtzrOE3UAawPqK1 b7EMxGkVzXfhTj6wfVWoWyOmvWsN/GfZBRhl3dlSj4BBqj1LpgGja7tX8E1T+2ClSfv9 ky9M3YKsDHAUw43X7Vw1PcUtcRYfvePka4fvsf1GvaPnoWX2BE3xLLU0Fm8ZF/8s0hFy qQNg== X-Gm-Message-State: AOAM531tGUbGIbxgE1W9WXoFCRoFy0hlgFteF+KlGLjLBasbAt0vVEDM VO7iRA4bbM7jujOEeEejgCQ= X-Google-Smtp-Source: ABdhPJxp3RfIIrJRTEpLIGOywEw5NI5gb1gC6rvIAZkMQ5gA+Ig+rra/ETQ7q7J+PbnPyAy+i6lLTw== X-Received: by 2002:a17:90b:3d0e:b0:1bb:8615:78d6 with SMTP id pt14-20020a17090b3d0e00b001bb861578d6mr7180187pjb.4.1645170235695; Thu, 17 Feb 2022 23:43:55 -0800 (PST) Received: from jrouhaud (2001-b011-1005-1e7d-64c0-fd4b-faaf-3e5d.dynamic-ip6.hinet.net. [2001:b011:1005:1e7d:64c0:fd4b:faaf:3e5d]) by smtp.gmail.com with ESMTPSA id g18sm1150145pfc.108.2022.02.17.23.43.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 23:43:55 -0800 (PST) Date: Fri, 18 Feb 2022 15:43:51 +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: <20220218074351.wgfosjt5lql2vjbr@jrouhaud> References: <20220217110515.zssjnez4lq2lmrdq@jrouhaud> <20220217172724.uhs2v3mgio7y6ga5@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 18, 2022 at 12:20:26PM +0530, Nitin Jadhav wrote: > > > > 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. > > Okay. I feel this can be added as additional field but it will not > replace backend_pid field as this represents the pid of the backend > which triggered the current checkpoint. I don't think that's true. Requesting a checkpoint means telling the checkpointer that it should wake up and start a checkpoint (or restore point) if it's not already doing so, so the pid will always be the checkpointer pid. The only exception is a standalone backend, but in that case you won't be able to query that view anyway. And also while looking at the patch I see there's the same problem that I mentioned in the previous thread, which is that the effective flags can be updated once the checkpoint started, and as-is the view won't reflect that. It also means that you can't simply display one of wal, time or force but a possible combination of the flags (including the one not handled in v1). > Probably a new field named 'processes_wiating' or 'events_waiting' can be > added for this purpose. Maybe num_process_waiting? > > > > > '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. > > Probably writing of buffers or syncing files may complete before > pg_is_in_recovery() returns false. But there are some cleanup > operations happen as part of the checkpoint. During this scenario, we > may get false value for pg_is_in_recovery(). Please refer following > piece of code which is present in CreateRestartpoint(). > > if (!RecoveryInProgress()) > replayTLI = XLogCtl->InsertTimeLineID; Then maybe we could store the timeline rather then then kind of checkpoint? You should still be able to compute the information while giving a bit more information for the same memory usage.