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 1ojSSR-0002M9-AL for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Oct 2022 21:43:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1ojSSP-0007aR-Ti for pgsql-hackers@arkaria.postgresql.org; Fri, 14 Oct 2022 21:43:05 +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 1ojSSP-0007Yi-HE for pgsql-hackers@lists.postgresql.org; Fri, 14 Oct 2022 21:43:05 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1ojSSL-0000vk-JS for pgsql-hackers@postgresql.org; Fri, 14 Oct 2022 21:43:05 +0000 Received: by mail-pl1-x632.google.com with SMTP id 10so5964493pli.0 for ; Fri, 14 Oct 2022 14:43:01 -0700 (PDT) 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=P9AX84d/9NVTDk60GGdf+Ak8ZxHn7IFLyoTgtqMplFk=; b=XCYqZoD2K6y2h5vcdDA1NDO/VExKyWNMWX/MobeVa3ZkLH3mUa+ZArjcE/O24QE9qm aTsyyIFj09rYVr5UcM85Z/wWfGXJ4eom6A8NcOZr61J/e0alRqIOU9+QyUmg0XcLWnm2 TXw0IRjUK2RygMjEOyNLQRtSP6puiLQktataTnpeHuoznJrphTSN7ciTdrWQ95smzUCW ugRINQV0efGV1i2tfSdKKPSRLqvuwFJOiLcaYKZZagkl1Vltr5gL4cfcTKb3TyDDIeeW J7ntOqH4YQNqty9/4fZNo7hF13nnZeRPljIo564dACYvs8fyr837NtqSCu/vCBkflktd kuAg== 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=P9AX84d/9NVTDk60GGdf+Ak8ZxHn7IFLyoTgtqMplFk=; b=ndKakB7hoTKDSyLyCLWkhcvkkscUO3ekEu/E9IKpYz0+cocXh3FVAQ2FKx6yRuxKOi aLZOcHXPuwgAvsl411OIXFJMAo4DgMDPqqwp1nJojzjOEyvcpCblS/YaDaF9LO0umWQ9 i1nBXPs/eCit6lGgKgvBS+l2Ap1IMHa5wP1+ZClUyjWYcUi8ZKzGNzoLQ48nlz5u1Ffb rNXX+wEdJ68Z6H4r2WLkjtKVM+Ty4OuBFJlxsowqPqJO3zuefldX5w/oEuhMRvOD32qR Mrl7+ut3jhe4XcfuwAgQHMBuojHy3qtQcGOs8ApmkTMVooDzWZvkz7zXsSzlyR4LDJqL lReA== X-Gm-Message-State: ACrzQf27c/0AleseV0798ejHYSmc5oUlQpB5raM8uu6m1cjKCphDdOjZ wW6GffCW45hWvSuVMGGlpfk= X-Google-Smtp-Source: AMsMyM4gRBp61NP1FXKN7v/8jgCFgSuDCSM/OvfWxktljFF8oUb1gDj+gcT2xmlta1duI/NKsAHiLw== X-Received: by 2002:a17:90b:17c7:b0:20b:7cb:9397 with SMTP id me7-20020a17090b17c700b0020b07cb9397mr14122573pjb.191.1665783779366; Fri, 14 Oct 2022 14:42:59 -0700 (PDT) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id z15-20020a17090a170f00b002009db534d1sm1872512pjd.24.2022.10.14.14.42.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Oct 2022 14:42:58 -0700 (PDT) Date: Fri, 14 Oct 2022 14:42:56 -0700 From: Nathan Bossart To: Bharath Rupireddy Cc: Michael Paquier , Tom Lane , Peter Eisentraut , Benoit =?iso-8859-1?Q?Lobr=E9au?= , Alvaro Herrera , Robert Haas , "Bossart, Nathan" , David Steele , Fujii Masao , "pgsql-hackers@postgresql.org" , Magnus Hagander , Stephen Frost Subject: Re: archive modules Message-ID: <20221014214256.GA1819154@nathanxps13> References: <20220923161402.GA736566@nathanxps13> <4f66de67-35a0-3fe7-fa61-d618e1bd2c2c@enterprisedb.com> <20221005185716.GB201192@nathanxps13> <1d9cb989-91b0-919e-f42b-4788f5fc7911@enterprisedb.com> <20221013182408.GA1551106@nathanxps13> <1061703.1665687218@sss.pgh.pa.us> <20221014185130.GC1678424@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="XsQoSWH+UP9D9v3l" Content-Disposition: inline In-Reply-To: <20221014185130.GC1678424@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Fri, Oct 14, 2022 at 11:51:30AM -0700, Nathan Bossart wrote: > On Fri, Oct 14, 2022 at 12:10:18PM +0530, Bharath Rupireddy wrote: >> 2) I think we have a problem - set archive_mode and archive_library >> and start the server, then set archive_command, reload the conf, see >> [3] - the archiver needs to error out right? The archiver gets >> restarted whenever archive_library changes but not when >> archive_command changes. I think the right place for the error is >> after or at the end of HandlePgArchInterrupts(). > > Good catch. You are right, this is broken. I believe that we need to > check for the misconfiguration in HandlePgArchInterrupts() in addition to > LoadArchiveLibrary(). I will work on fixing this. As promised... -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --XsQoSWH+UP9D9v3l Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="fail_arch_v2.patch" diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 66312b53b8..9d0f3608c4 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3597,9 +3597,11 @@ include_dir 'conf.d' This parameter can only be set in the postgresql.conf - file or on the server command line. It is ignored unless + file or on the server command line. It is only used if archive_mode was enabled at server start and - archive_library is set to an empty string. + archive_library is set to an empty string. If both + archive_command and archive_library + are set, archiving will fail. If archive_command is an empty string (the default) while archive_mode is enabled (and archive_library is set to an empty string), WAL archiving is temporarily @@ -3624,7 +3626,9 @@ include_dir 'conf.d' The library to use for archiving completed WAL file segments. If set to an empty string (the default), archiving via shell is enabled, and - is used. Otherwise, the specified + is used. If both + archive_command and archive_library + are set, archiving will fail. Otherwise, the specified shared library is used for archiving. For more information, see and . diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 3868cd7bd3..39c2115943 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -801,7 +801,8 @@ HandlePgArchInterrupts(void) archiveLibChanged = strcmp(XLogArchiveLibrary, archiveLib) != 0; pfree(archiveLib); - if (archiveLibChanged) + if (archiveLibChanged || + (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0')) { /* * Call the currently loaded archive module's shutdown callback, @@ -809,17 +810,25 @@ HandlePgArchInterrupts(void) */ call_archive_module_shutdown_callback(0, 0); - /* - * Ideally, we would simply unload the previous archive module and - * load the new one, but there is presently no mechanism for - * unloading a library (see the comment above - * internal_load_library()). To deal with this, we simply restart - * the archiver. The new archive module will be loaded when the - * new archiver process starts up. - */ - ereport(LOG, - (errmsg("restarting archiver process because value of " - "\"archive_library\" was changed"))); + if (archiveLibChanged) + { + /* + * Ideally, we would simply unload the previous archive module + * and load the new one, but there is presently no mechanism + * for unloading a library (see the comment above + * internal_load_library()). To deal with this, we simply + * restart the archiver. The new archive module will be loaded + * when the new archiver process starts up. + */ + ereport(LOG, + (errmsg("restarting archiver process because value of " + "\"archive_library\" was changed"))); + } + else + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("both archive_command and archive_library specified"), + errdetail("Only one of archive_command, archive_library may be set."))); proc_exit(0); } @@ -836,6 +845,12 @@ LoadArchiveLibrary(void) { ArchiveModuleInit archive_init; + if (XLogArchiveLibrary[0] != '\0' && XLogArchiveCommand[0] != '\0') + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + errmsg("both archive_command and archive_library specified"), + errdetail("Only one of archive_command, archive_library may be set."))); + memset(&ArchiveContext, 0, sizeof(ArchiveModuleCallbacks)); /* --XsQoSWH+UP9D9v3l--