pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alvaro Herrera <alvherre@2ndquadrant.com>
To: Andres Freund <andres@anarazel.de>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: jgdr@dalibo.com
Cc: michael@paquier.xyz
Cc: sawada.mshk@gmail.com
Cc: peter.eisentraut@2ndquadrant.com
Cc: pgsql-hackers@lists.postgresql.org
Cc: thomas.munro@enterprisedb.com
Cc: sk@zsrv.org
Cc: michael.paquier@gmail.com
Subject: Re: [HACKERS] Restricting maximum keep segments by repslots
Date: Mon, 18 May 2020 19:44:59 -0400
Message-ID: <20200518234459.GA1850@alvherre.pgsql> (raw)
In-Reply-To: <20200517025150.GA12478@alvherre.pgsql>

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

Attachments:

  [text/x-diff] 0001-CreateCheckPoint-return-bool.patch (2.1K, ../20200518234459.GA1850@alvherre.pgsql/2-0001-CreateCheckPoint-return-bool.patch)
  download | inline diff:
From 9148a6defa2e8b3fd81b982de53f73584a8b3d10 Mon Sep 17 00:00:00 2001
From: Alvaro Herrera <alvherre@alvh.no-ip.org>
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

view thread (143+ messages)  latest in thread

Message-ID: <20200518234459.GA1850@alvherre.pgsql>
Permalink:  ../20200518234459.GA1850@alvherre.pgsql/
Also on:    postgresql.org/message-id/20200518234459.GA1850@alvherre.pgsql

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-hackers@postgresql.org
  Cc: alvherre@2ndquadrant.com, andres@anarazel.de, horikyota.ntt@gmail.com, 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
  In-Reply-To: <20200518234459.GA1850@alvherre.pgsql>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox