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 1nLIN8-0006EV-UG for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Feb 2022 05:33:31 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nLIMb-0007KT-FA for pgsql-hackers@arkaria.postgresql.org; Sat, 19 Feb 2022 05:32:57 +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 1nLIMb-0007KK-3t for pgsql-hackers@lists.postgresql.org; Sat, 19 Feb 2022 05:32:57 +0000 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nLIMW-0005oZ-Sj for pgsql-hackers@lists.postgresql.org; Sat, 19 Feb 2022 05:32:56 +0000 Received: by mail-pj1-x1033.google.com with SMTP id r64-20020a17090a43c600b001b8854e682eso10428421pjg.0 for ; Fri, 18 Feb 2022 21:32:52 -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=NSqCk1kqI+S5/bK9zYxTBupBRjxpNsk3bCImTvY0liQ=; b=h9OlIvCVgJBG6B3HpHiGiHPMbyW+j8RxFZkoBRzQcPaO7Kts5ui1x0ZEFlO969GIDt tNXC29yjizETGh9SbEXDe5CCKHTzlfqpSrSjsLJw6yu7SlwM/NTcUQu/J06kZ+QNehAG whHtkV7eDYMH4EdjklkcyN7QtbRFWMCnkexUy4lQkStZ2FftrLxGvLT+ktI7BgztMI1t jZXzzO6BzP6OCbME8pbNFGaBPLJX8IveyDfmJNof1O3p4riKG/mlG8Zlz5vWYCptUUVE PbUVvrzZDpjxt2DqMZjupxdee2G2+qamneYwVV9g2kZdsCex1ip8Zc0q55gxDWjtGCnh 3xoA== 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=NSqCk1kqI+S5/bK9zYxTBupBRjxpNsk3bCImTvY0liQ=; b=ocqSz+BAX8D+5dVAVvwQjEesYBLYOJ8ig56i6V7Pqskz8nQt20cXV61oRfqG+S7xQh /pO+EZcTHPn5XAW/1tVVtEsZ03/c8vPHvaD4agcrR38lsuoq6qlwnhsNYJ2j8URZfbth iPjBlpYNFz6zwU6c9Cl1zUW24ek6mLGf6Sk8nNu9LC1ixwFnpZLf3HeVZgqdOahO/Esk FVSyzS6ZtOKkGZEh2kjX59thQy/7QqXzVLXaaYpuWrtu2rTdfoFrg0mtqeg04JPvwzFO OyKb+88iab1UFkPj9hAodpFoTIp3qYupNc/0a1Zh62ZxcRjimkNh9mjMdI4JZVTh9ab/ MCVQ== X-Gm-Message-State: AOAM5336iftq1JJtP3SUZX1+NvYRDSA/iYaSaEz95qUzyWUGOdl7EI6q vMTWVl9rH9OdhwNuiRvXQl0= X-Google-Smtp-Source: ABdhPJz6Y6DRhpDJxFIwHGllKkJ6Id4B5RX0DpqyQLWPB4udyCEOQl8RTn4u6ZnQv/FBHzOs5ji2Wg== X-Received: by 2002:a17:902:e94f:b0:14f:1636:c8a8 with SMTP id b15-20020a170902e94f00b0014f1636c8a8mr10251644pll.130.1645248770843; Fri, 18 Feb 2022 21:32:50 -0800 (PST) Received: from jrouhaud (1-171-157-197.dynamic-ip.hinet.net. [1.171.157.197]) by smtp.gmail.com with ESMTPSA id t1sm12276476pgj.43.2022.02.18.21.32.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Feb 2022 21:32:50 -0800 (PST) Date: Sat, 19 Feb 2022 13:32:15 +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: <20220219053215.r4wqatln5awklecf@jrouhaud> References: <20220217110515.zssjnez4lq2lmrdq@jrouhaud> <20220217172724.uhs2v3mgio7y6ga5@jrouhaud> <20220218074351.wgfosjt5lql2vjbr@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 08:07:05PM +0530, Nitin Jadhav wrote: > > The backend_pid contains a valid value only during > the CHECKPOINT command issued by the backend explicitly, otherwise the > value will be 0. We may have to add an additional field to > 'CheckpointerShmemStruct' to hold the backend pid. The backend > requesting the checkpoint will update its pid to this structure. > Kindly let me know if you still feel the backend_pid field is not > necessary. There are more scenarios where you can have a baackend requesting a checkpoint and waiting for its completion, and there may be more than one backend concerned, so I don't think that storing only one / the first backend pid is ok. > > 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). > > If I understand the above comment properly, it has 2 points. First is > to display the combination of flags rather than just displaying wal, > time or force - The idea behind this is to just let the user know the > reason for checkpointing. That is, the checkpoint is started because > max_wal_size is reached or checkpoint_timeout expired or explicitly > issued CHECKPOINT command. The other flags like CHECKPOINT_IMMEDIATE, > CHECKPOINT_WAIT or CHECKPOINT_FLUSH_ALL indicate how the checkpoint > has to be performed. Hence I have not included those in the view. If > it is really required, I would like to modify the code to include > other flags and display the combination. I think all the information should be exposed. Only knowing why the current checkpoint has been triggered without any further information seems a bit useless. Think for instance for cases like [1]. > Second point is to reflect > the updated flags in the view. AFAIK, there is a possibility that the > flags get updated during the on-going checkpoint but the reason for > checkpoint (wal, time or force) will remain same for the current > checkpoint. There might be a change in how checkpoint has to be > performed if CHECKPOINT_IMMEDIATE flag is set. If we go with > displaying the combination of flags in the view, then probably we may > have to reflect this in the view. You can only "upgrade" a checkpoint, but not "downgrade" it. So if for instance you find both CHECKPOINT_CAUSE_TIME and CHECKPOINT_FORCE (which is possible) you can easily know which one was the one that triggered the checkpoint and which one was added later. > > > Probably a new field named 'processes_wiating' or 'events_waiting' can be > > > added for this purpose. > > > > Maybe num_process_waiting? > > I feel 'processes_wiating' aligns more with the naming conventions of > the fields of the existing progres views. There's at least pg_stat_progress_vacuum.num_dead_tuples. Anyway I don't have a strong opinion on it, just make sure to correct the typo. > > > 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. > > Can you please describe more about how checkpoint/restartpoint can be > confirmed using the timeline id. If pg_is_in_recovery() is true, then it's a restartpoint, otherwise it's a restartpoint if the checkpoint's timeline is different from the current timeline? [1] https://www.postgresql.org/message-id/1486805889.24568.96.camel%40credativ.de