pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Sravan Kumar <sravanvcybage@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Cc: bharath.rupireddyforpostgres@gmail.com
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: Question regarding "Make archiver process an auxiliary process. commit"
Date: Tue, 31 Jan 2023 20:30:13 -0800
Message-ID: <20230201043013.GA3194884@nathanxps13> (raw)
In-Reply-To: <20230120193956.GA2831@nathanxps13>
References: <CA+=NbjiGSTqNE=njikNrX1=R=SXGaxV-A22qZ2nH8=O0B6SSAg@mail.gmail.com>
	<CALj2ACV3HsLWTwQDfdS6w-8_FfpPpRE5WYJ7-At7pk7K_7HuaQ@mail.gmail.com>
	<CA+=Nbjhxyj54hs4TvdPmRsGfxWLQPagzPQysOGKMP5sMo6aLFw@mail.gmail.com>
	<20221207.151939.662411275254345514.horikyota.ntt@gmail.com>
	<CA+=NbjhEx-dZx=xqbj30ym-zQg9HygEYRdYdwZC9a471Wv92_w@mail.gmail.com>
	<20230120193956.GA2831@nathanxps13>

On Fri, Jan 20, 2023 at 11:39:56AM -0800, Nathan Bossart wrote:
> I noticed that time.h is no longer needed by the archiver, so I removed
> that and fixed an indentation nitpick in the attached v2.  I'm going to set
> the commitfest entry to ready-for-committer shortly after sending this
> message.

I'm not sure why I thought time.h was no longer needed.  time() is clearly
used elsewhere in this file.  Here's a new version with that added back.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com

Attachments:

  [text/x-diff] v3-0001-simplify-wait-loop-in-the-archiver.patch (1.8K, ../20230201043013.GA3194884@nathanxps13/2-v3-0001-simplify-wait-loop-in-the-archiver.patch)
  download | inline diff:
From 3313989a30b0821ed7014527b0342e7c63b59169 Mon Sep 17 00:00:00 2001
From: Sravan Velagandula <sravan.velagandula@enterprisedb.com>
Date: Tue, 6 Dec 2022 06:21:38 -0500
Subject: [PATCH v3 1/1] simplify wait loop in the archiver

---
 src/backend/postmaster/pgarch.c | 28 +++++++++-------------------
 1 file changed, 9 insertions(+), 19 deletions(-)

diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c
index 8ecdb9ca23..51d882c17a 100644
--- a/src/backend/postmaster/pgarch.c
+++ b/src/backend/postmaster/pgarch.c
@@ -297,7 +297,6 @@ pgarch_waken_stop(SIGNAL_ARGS)
 static void
 pgarch_MainLoop(void)
 {
-	pg_time_t	last_copy_time = 0;
 	bool		time_to_stop;
 
 	/*
@@ -335,30 +334,21 @@ pgarch_MainLoop(void)
 
 		/* Do what we're here for */
 		pgarch_ArchiverCopyLoop();
-		last_copy_time = time(NULL);
 
 		/*
 		 * Sleep until a signal is received, or until a poll is forced by
-		 * PGARCH_AUTOWAKE_INTERVAL having passed since last_copy_time, or
-		 * until postmaster dies.
+		 * PGARCH_AUTOWAKE_INTERVAL, or until postmaster dies.
 		 */
 		if (!time_to_stop)		/* Don't wait during last iteration */
 		{
-			pg_time_t	curtime = (pg_time_t) time(NULL);
-			int			timeout;
-
-			timeout = PGARCH_AUTOWAKE_INTERVAL - (curtime - last_copy_time);
-			if (timeout > 0)
-			{
-				int			rc;
-
-				rc = WaitLatch(MyLatch,
-							   WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
-							   timeout * 1000L,
-							   WAIT_EVENT_ARCHIVER_MAIN);
-				if (rc & WL_POSTMASTER_DEATH)
-					time_to_stop = true;
-			}
+			int			rc;
+
+			rc = WaitLatch(MyLatch,
+						   WL_LATCH_SET | WL_TIMEOUT | WL_POSTMASTER_DEATH,
+						   PGARCH_AUTOWAKE_INTERVAL * 1000L,
+						   WAIT_EVENT_ARCHIVER_MAIN);
+			if (rc & WL_POSTMASTER_DEATH)
+				time_to_stop = true;
 		}
 
 		/*
-- 
2.25.1

view thread (11+ messages)  latest in thread

Message-ID: <20230201043013.GA3194884@nathanxps13>
Permalink:  ../20230201043013.GA3194884@nathanxps13/
Also on:    postgresql.org/message-id/20230201043013.GA3194884@nathanxps13

 ·  · 

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: nathandbossart@gmail.com, sravanvcybage@gmail.com, horikyota.ntt@gmail.com, bharath.rupireddyforpostgres@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: Question regarding "Make archiver process an auxiliary process. commit"
  In-Reply-To: <20230201043013.GA3194884@nathanxps13>

* 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