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 1pN4lK-0001Bh-Ho for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2023 04:30:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pN4lJ-0007wZ-Dm for pgsql-hackers@arkaria.postgresql.org; Wed, 01 Feb 2023 04:30:21 +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 1pN4lJ-0007wQ-2r for pgsql-hackers@lists.postgresql.org; Wed, 01 Feb 2023 04:30:21 +0000 Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pN4lG-0007SB-KE for pgsql-hackers@lists.postgresql.org; Wed, 01 Feb 2023 04:30:20 +0000 Received: by mail-pl1-x635.google.com with SMTP id m13so5364202plx.13 for ; Tue, 31 Jan 2023 20:30:18 -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=+aZBuf/Hqt9Bi7GENi9PJg0/YacQ20PseBVYDi3+gBI=; b=drXtSc/2mONAOpNec0DQoyjWbRYE6dJquodKc6vpud87WWXuuvzPS7Y3r8SC9GIyr3 Jlp3Na//PIkDlw7PMX4PLQbSs9uLEfiPHqdVsEkF0bP5RbBTnOcbXuPAvMU5GLvo+wTn mFWm6MXO2rzclUhhx2WwgBF+n08YFeUAHQadWof04tipm94UPJ7V2JHNnxf5Vy8m9JO1 koOGvfd0qfxL3bmbQI7NlVcOEt5L41sdDmffrWIVOVz+gyCIqFdPGFOmrUVfFPgzLoc0 V85HB8ArBl08IqKKcc8UIrSNUSRaiktNBYzh/L7S5GsLQZo5kqf6+k+Ba/Q16oBA0oGG 0FPw== 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=+aZBuf/Hqt9Bi7GENi9PJg0/YacQ20PseBVYDi3+gBI=; b=TfUE2tCknDT0OzduHfhCs43gSGcRTFJAZXwoPo0eUSboX5np47bHDFIZyNLp1bK8TV MPT1266WQE5v3Ia/faxDMqWF/RMR7LqspMbgHaw3LGwu1+FWn9sioRjaK6myJ3TQM2y+ m7GXWjGvdVtF9wacZvqSQee3CzYlj/admh34V3hJ5SJw8GrLTikP5LlCGfnKuqCEb+JT POm0KSQs9sWr5SpDIWY9eccIKguqERwixZWjMwkdPODSdaFPRRsGdocVr96igwBaCpRw 166+anr4+78tLSBvCCbn09BHeROlqkunvoC5Cc4agvXkccgK/O5mePQ5et01KILYfNRn D2Lg== X-Gm-Message-State: AO0yUKUcVJwBopFJkWmhFdbgkcI4DmI9bq9NNn5+LKw2Ubpkg2OeP6Sx J4Jrmcv2VwLYP3Cdal+dbLI= X-Google-Smtp-Source: AK7set+MgkSZA1A8f6B6E4GArRJL25SqVNI5y+iBRNS2a3NVIIv7jVTDRmuGIERpbofvL0d0LLDKYA== X-Received: by 2002:a17:90a:1955:b0:22b:fcb6:c7cc with SMTP id 21-20020a17090a195500b0022bfcb6c7ccmr730510pjh.29.1675225816188; Tue, 31 Jan 2023 20:30:16 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id js12-20020a17090b148c00b0022be5d70acdsm285337pjb.20.2023.01.31.20.30.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Jan 2023 20:30:15 -0800 (PST) Date: Tue, 31 Jan 2023 20:30:13 -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: <20230201043013.GA3194884@nathanxps13> References: <20221207.151939.662411275254345514.horikyota.ntt@gmail.com> <20230120193956.GA2831@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="9jxsPFA5p3P2qPhR" Content-Disposition: inline In-Reply-To: <20230120193956.GA2831@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --9jxsPFA5p3P2qPhR Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --9jxsPFA5p3P2qPhR Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v3-0001-simplify-wait-loop-in-the-archiver.patch" From 3313989a30b0821ed7014527b0342e7c63b59169 Mon Sep 17 00:00:00 2001 From: Sravan Velagandula 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 --9jxsPFA5p3P2qPhR--