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 1japRr-0008Qh-64 for pgsql-hackers@arkaria.postgresql.org; Mon, 18 May 2020 23:45: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 1japRp-0006yV-QG for pgsql-hackers@arkaria.postgresql.org; Mon, 18 May 2020 23:45:29 +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 1japRp-0006yN-Jq for pgsql-hackers@lists.postgresql.org; Mon, 18 May 2020 23:45:29 +0000 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1japRP-0000ID-JW for pgsql-hackers@lists.postgresql.org; Mon, 18 May 2020 23:45:28 +0000 Received: by mail-qt1-x842.google.com with SMTP id n22so7248194qtv.12 for ; Mon, 18 May 2020 16:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=xcITZBKDgK+q4Mcv/7nw/JvnkRUnrwdQefaule2Lm3E=; b=VFYS6/XPzcrD9GDUahPBGjMT7w9ZS+bCD1J+mTzCWeOwV9U1iLbJ6yST+jh9i2TgZw KdUpwMx4+ZqeK4pem3V7tpqsvWmcLHRrYUl6Ksa/539w8NttujQUexcCvxa5+ZSdRzIE fdwkngCuEwVd2yhoa6qjk1BtczssHLK+Qz+MCj2uxueeUL5QmwM8Yl2Ke851aKsQNnAw RtYR9myxVQWUG8QeYex5fyMLrci3ZkgwQWcjRvMqnDP5j01fNqRBf6nK1tBVaODZpgNp 0TPJuvrNXrV1uJJuT8HAceVX68uI3G6hpX1fcMu2r3cOe0sLJT+q0l2pLRwhuQvLkqAn m90A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=xcITZBKDgK+q4Mcv/7nw/JvnkRUnrwdQefaule2Lm3E=; b=uSknZ36v4QWFDQhjsQSLZCQRG2WMYcE5Du/IcDEaeeJbSasGnVOjJ8+RjFTch4hlnG K+AT89c7V0HMz9POjL981SOloWABzEQMB6UKcvIBwJ22bUL7zxft3gZOs5Le+rBsFkuB qYgP4Sn5zOK8EgwVLRGUMr73f049yro6JGghkfM7PmQhP8HT4mH1oIS/1bPUryJrk6zm DXClPonrIy1R8wk9S4PDRpWbOJIP7oriccSvu0GxWBGESXfTEw5OjwN8iQxCTWF+HD1B X7k08ltO4kqBAjdrXO9w1Gjow7vK+fpleRukiey0RfzQnvI3Y5C/uEkIYWwPa29tTdUo Cf8A== X-Gm-Message-State: AOAM533Df216Z7HRDdEw6Q87XL6DnNqc7tcj/8oD2qfU/FqTvP3fOIGc qDojKi/jmEY6shF3cL4bwrYmsQ== X-Google-Smtp-Source: ABdhPJyoqMZl+cNbevsy80AC4uRJniOk0q0kzblpzKLSUpCHobIMg7iAA7xMXnhKz3v54ySLPnFYDw== X-Received: by 2002:ac8:66d2:: with SMTP id m18mr19211503qtp.302.1589845502463; Mon, 18 May 2020 16:45:02 -0700 (PDT) Received: from nimloth.alvh.no-ip.org ([190.95.18.252]) by smtp.gmail.com with ESMTPSA id n184sm9377082qkf.0.2020.05.18.16.45.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 May 2020 16:45:00 -0700 (PDT) Received: by nimloth.alvh.no-ip.org (Postfix, from userid 1000) id 3537530076A; Mon, 18 May 2020 19:44:59 -0400 (-04) Date: Mon, 18 May 2020 19:44:59 -0400 From: Alvaro Herrera To: Andres Freund Cc: Kyotaro Horiguchi , jgdr@dalibo.com, michael@paquier.xyz, sawada.mshk@gmail.com, peter.eisentraut@2ndquadrant.com, pgsql-hackers@lists.postgresql.org, thomas.munro@enterprisedb.com, sk@zsrv.org, michael.paquier@gmail.com Subject: Re: [HACKERS] Restricting maximum keep segments by repslots Message-ID: <20200518234459.GA1850@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="mYCpIKhGyMATD0i+" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200517025150.GA12478@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --mYCpIKhGyMATD0i+ Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit BTW while you're messing with checkpointer, I propose this patch to simplify things. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --mYCpIKhGyMATD0i+ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-CreateCheckPoint-return-bool.patch" From 9148a6defa2e8b3fd81b982de53f73584a8b3d10 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Fri, 8 May 2020 15:28:57 -0400 Subject: [PATCH] CreateCheckPoint return bool --- src/backend/access/transam/xlog.c | 13 +++++++++++-- src/backend/postmaster/checkpointer.c | 9 ++------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index ca09d81b08..8990ef7348 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -8695,8 +8695,10 @@ UpdateCheckPointDistanceEstimate(uint64 nbytes) * All of this mechanism allows us to continue working while we checkpoint. * As a result, timing of actions is critical here and be careful to note that * this function will likely take minutes to execute on a busy system. + * + * Return value is true. */ -void +bool CreateCheckPoint(int flags) { bool shutdown; @@ -8815,7 +8817,12 @@ CreateCheckPoint(int flags) END_CRIT_SECTION(); ereport(DEBUG1, (errmsg("checkpoint skipped because system is idle"))); - return; + + /* + * Returns true even if checkpoint is skipped; this is required to + * prevent breaking the checkpoint scheduling algorithm. + */ + return true; } } @@ -9107,6 +9114,8 @@ CreateCheckPoint(int flags) CheckpointStats.ckpt_segs_recycled); LWLockRelease(CheckpointLock); + + return true; } /* diff --git a/src/backend/postmaster/checkpointer.c b/src/backend/postmaster/checkpointer.c index 34ed9f7887..380b243547 100644 --- a/src/backend/postmaster/checkpointer.c +++ b/src/backend/postmaster/checkpointer.c @@ -436,13 +436,8 @@ CheckpointerMain(void) /* * Do the checkpoint. */ - if (!do_restartpoint) - { - CreateCheckPoint(flags); - ckpt_performed = true; - } - else - ckpt_performed = CreateRestartPoint(flags); + ckpt_performed = do_restartpoint ? + CreateRestartPoint(flags) : CreateCheckPoint(flags); /* * After any checkpoint, close all smgr files. This is so we -- 2.20.1 --mYCpIKhGyMATD0i+--