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 1pIxF7-0002rS-Jx for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Jan 2023 19:40:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pIxF6-0007GX-Hc for pgsql-hackers@arkaria.postgresql.org; Fri, 20 Jan 2023 19:40:04 +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 1pIxF6-0007GL-84 for pgsql-hackers@lists.postgresql.org; Fri, 20 Jan 2023 19:40:04 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pIxF3-00073O-N9 for pgsql-hackers@lists.postgresql.org; Fri, 20 Jan 2023 19:40:03 +0000 Received: by mail-pj1-x1031.google.com with SMTP id m3-20020a17090a414300b00229ef93c5b0so5204501pjg.2 for ; Fri, 20 Jan 2023 11:40:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=aeIDsKHfQH7+AGntalAHEO0c/R9sgPVjYcEgxayAtoc=; b=k1iihsJQLvu+YJQ8xXQtIroc+Olw2Vlw88Neqj9v3YIyEid03FbOLM3nTuFk6tJh2b to1TB7RioiK13d+pNyGlGE6RhD5WtE0IlkvJLEoguf5SdK17+U8EzVyrtslkGNHSF8H8 u0pOIetKw640HuK54BUTpv1avhTZTw/Gu+NlzaKEl8y2Fjfc+UApR6LLELlI1df7jhHh HEYGqqS3WTZQDI1I3K2uMDBVo3QHcRxdiK7vTw0tlBBwtsKIFK5QoGBful8s/9zCb0PD Nq6a0C0pmrLIOBdtd/wgpPaz7eiqVEE0LGuuDym0PCfad2bvHmlWW+VnG0G8HaViL93p JznA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=aeIDsKHfQH7+AGntalAHEO0c/R9sgPVjYcEgxayAtoc=; b=ZTYrzNheeTwAbJoNazTRAtW//bl4XzFKMJcFhJ782kSOaGX5usuid9Wtk0KHh5ooh9 qvdqUZ3mPJWBxI/nEyBegl+ZnhOQNJHU9P6xWJJoloY06wrDx0JFastG6K48m3/tJKNw MabpYwwu+fbmuwzaGPRAfVgFo0jnnCcmPXE9JSQCKdQZ+InjVMlfLnGbsybPkG9dj6WD mY+vhfDWD5SRE3POmm8nmdpZUz3H0xrPYrszghkMQSMyethujlM7eAvJZzvKjKklJdx9 PgyYcnxg5N7GAHhjwcsNuaXucwQ40rFGEadTo7rfMGUyLqNk9iTVonyElDfnvd5FBtPN bWkQ== X-Gm-Message-State: AFqh2krXd9A1ilEQoFbXO5IYc5RmcFBthNVRYTHiafBAYu9+d/7VSYEj 2SykBroBC2pZzqkGiPphGFM= X-Google-Smtp-Source: AMrXdXsqxtC7sPvSyqQH9o5WZmWQRXVGudZ/qvGuwCBOBIavlePCcxZqY06Og38fdzpaVk3yumpN3w== X-Received: by 2002:a17:903:2289:b0:194:9290:fa6f with SMTP id b9-20020a170903228900b001949290fa6fmr23513859plh.25.1674243599443; Fri, 20 Jan 2023 11:39:59 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id w3-20020a170902e88300b00189e7cb8b89sm10631161plg.127.2023.01.20.11.39.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 11:39:58 -0800 (PST) Date: Fri, 20 Jan 2023 11:39:56 -0800 From: Nathan Bossart To: Sravan Kumar Cc: Kyotaro Horiguchi , bharath.rupireddyforpostgres@gmail.com, pgsql-hackers@lists.postgresql.org Subject: Re: Question regarding "Make archiver process an auxiliary process. commit" Message-ID: <20230120193956.GA2831@nathanxps13> References: <20221207.151939.662411275254345514.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="J/dobhs11T7y2rNN" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --J/dobhs11T7y2rNN Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jan 04, 2023 at 11:35:33AM +0530, Sravan Kumar wrote: > I have added the thread to the commitfest: https://commitfest.postgresql.org/42/ > Did you get a chance to review the patch? Please let me know if you > need anything from my end. This seems like worthwhile simplification to me. Ultimately, your patch shouldn't result in any sort of signficant behavior change, and I don't see any reason to further complicate the timeout calculation. The copy loop will run any time the archiver's latch is set, and it'll wait up to 60 seconds otherwise. As discussed upthread, it might be possible to remove the timeout completely, but that probably deserves its own thread. 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. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --J/dobhs11T7y2rNN Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v2-0001-simplify-wait-loop-in-the-archiver.patch" From a06609e839f039b7e7806456eaf4ee113cfabc3c Mon Sep 17 00:00:00 2001 From: Sravan Velagandula Date: Tue, 6 Dec 2022 06:21:38 -0500 Subject: [PATCH v2 1/1] simplify wait loop in the archiver --- src/backend/postmaster/pgarch.c | 29 +++++++++-------------------- 1 file changed, 9 insertions(+), 20 deletions(-) diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 8ecdb9ca23..6e28067596 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -25,7 +25,6 @@ */ #include "postgres.h" -#include #include #include @@ -297,7 +296,6 @@ pgarch_waken_stop(SIGNAL_ARGS) static void pgarch_MainLoop(void) { - pg_time_t last_copy_time = 0; bool time_to_stop; /* @@ -335,30 +333,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 --J/dobhs11T7y2rNN--