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 1o9VfR-0002mB-6B for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 17:51:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1o9VfP-0006VR-50 for pgsql-hackers@arkaria.postgresql.org; Thu, 07 Jul 2022 17:51:55 +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 1o9VfO-0006Os-Q3 for pgsql-hackers@lists.postgresql.org; Thu, 07 Jul 2022 17:51:54 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1o9VfH-00018K-MJ for pgsql-hackers@postgresql.org; Thu, 07 Jul 2022 17:51:54 +0000 Received: by mail-pf1-x432.google.com with SMTP id e16so8106428pfm.11 for ; Thu, 07 Jul 2022 10:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MutZ82VsJFe6JUZRwGkv/09dk97P39gslPQUDPw7cME=; b=oSwnZ4E5yp5xP6RA0XWxGG3p4S0aO+X3vzKsD23sIQyQzzmdE5MJfslnZtt+392oSx T7/GPHSkiuIPPdjvH6yy0Csvf/UNhIZbUupswIdlZekueVkF8A7j7BmhxXdjYBRD0wjP b8rporKYXfMQfFVqTUjSwLUXapaZx/hxs/Trtk7aWLkBHD52FLmllMMEdoUcEiJBU5kC EVMQKTV57G9Yu/Xt42nywNjqWs7rOkjAOU/PaMzPGFFqP3aX8Z7W0HU0IA3mcPG8T4FG U31CnYX4UQUbV0AMWONSsit059E3zanaZf2n+hkxmUBRVLzRUejNWwIlZdcQ/0uxvmWu gecA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MutZ82VsJFe6JUZRwGkv/09dk97P39gslPQUDPw7cME=; b=2hZQCPE/5lCIizL0CzhqtwNjJqlvIExBjGY6CxmqAKMggf06Ti5zjGra53U+u9s15+ ntkyua8iS9BZpkObIW0fyXDk9zFhiyrR1243/YxnDN+6Z0EMTFVlZAPT+IZPhtt/mMAK laJxifqLVSQl9yiOMnKbgWTWsj2IZKECb9r10TkkeI4rh4NdHVBkEgcBGGOhHo7Lx4aZ Dk3tN2yG168bCEk2gmq2uYomSQhUKmVFbNXLvRlSeVddO+2VigjkPvmwIDQumKE/CGLt zUpMOldDhPXdj8Ps4PaZdpLGxGVrqZeB+dcRWS7kT4M64/omxhZYNWpW+1vSfSPNrOnl XAGw== X-Gm-Message-State: AJIora+dyxxn9D5OBIaUFcsHPsFHwykizMJ72snNk8zDcmiAD5/SF28w 3vHwlDyy4wYigfdRyHm89a0= X-Google-Smtp-Source: AGRyM1u9rEAjOT64k5HZ13SihCNu0G5DKNlB9QOQaA7DDwu8Cf0CIndVfOsnH1SAZGXldlCYoqo65A== X-Received: by 2002:a17:90b:4f4e:b0:1ef:ab40:b345 with SMTP id pj14-20020a17090b4f4e00b001efab40b345mr6581055pjb.226.1657216305418; Thu, 07 Jul 2022 10:51:45 -0700 (PDT) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id y62-20020a626441000000b0050dc76281d3sm958170pfb.173.2022.07.07.10.51.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 10:51:44 -0700 (PDT) Date: Thu, 7 Jul 2022 10:51:42 -0700 From: Nathan Bossart To: David Steele Cc: Robert Haas , Fujii Masao , Kyotaro Horiguchi , "pgsql-hackers@postgresql.org" Subject: Re: remove more archiving overhead Message-ID: <20220707175142.GA2254092@nathanxps13> References: <20220222011948.GA3850532@nathanxps13> <20220222173711.GA3852671@nathanxps13> <20220222195229.GA42988@nathanxps13> <20220224.141349.1809640551882183816.horikyota.ntt@gmail.com> <20220224175553.GA660690@nathanxps13> <20220407222327.GA1363808@nathanxps13> <768e6cb3-256d-9c0b-1797-62420ffca7ae@oss.nttdata.com> <17147b74-5465-9a7a-ae27-305d1200482c@pgmasters.net> <20220707161825.GA2205004@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="SLDf9lqlvOQaIe6s" Content-Disposition: inline In-Reply-To: <20220707161825.GA2205004@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --SLDf9lqlvOQaIe6s Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Jul 07, 2022 at 09:18:25AM -0700, Nathan Bossart wrote: > On Thu, Jul 07, 2022 at 10:46:23AM -0400, David Steele wrote: >> On 7/7/22 10:37, Robert Haas wrote: >>> I don't object, but I just started to wonder whether the need to >>> handle re-archiving of the same file cleanly is as well-documented as >>> it ought to be. >> >> +1, but I don't think that needs to stand in the way of this patch, which >> looks sensible to me as-is. I think that's what you meant, but just wanted >> to be sure. > > Yeah, this seems like something that should be documented. I can pick this > up. I believe this is an existing problem, but this patch could make it > more likely. Here is a first try at documenting this. I'm not thrilled about the placement, since it feels a bit buried in the backup docs, but this is where this sort of thing lives today. It also seems odd to stress the importance of avoiding overwriting pre-existing archives in case multiple servers are archiving to the same place while only offering solutions with obvious race conditions. Even basic_archive is subject to this now that durable_rename_excl() no longer exists. Perhaps we should make a note of that, too. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --SLDf9lqlvOQaIe6s Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-add-note-about-re-archiving-in-docs.patch" From 2b563823ca8dc57ea386832ea0b8c4c472645117 Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Thu, 7 Jul 2022 10:43:30 -0700 Subject: [PATCH v1 1/1] add note about re-archiving in docs --- doc/src/sgml/backup.sgml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/backup.sgml b/doc/src/sgml/backup.sgml index 73a774d3d7..dd1c360455 100644 --- a/doc/src/sgml/backup.sgml +++ b/doc/src/sgml/backup.sgml @@ -685,10 +685,24 @@ test ! -f /mnt/server/archivedir/00000001000000A900000065 && cp pg_wal/0 - It is advisable to test your proposed archive library to ensure that it - indeed does not overwrite an existing file, and that it returns - false in this case. - The example command above for Unix ensures this by including a separate + In rare cases, PostgreSQL may attempt to + re-archive a WAL file that was previously archived. For example, if the + system crashes before the server makes a durable record of archival success, + the server will attempt to archive the file again after restarting (provided + archiving is still enabled). It is advisable to test your proposed archive + library to ensure that it indeed does not overwrite an existing file. When + a pre-existing file is encountered, the archive library may return + true if the WAL file has identical contents to the + pre-existing archive. Alternatively, the archive library can return + false anytime a pre-existing file is encountered, but + this will require manual action by an administrator to resolve. If a + pre-existing file contains different contents than the WAL file being + archived, the archive library must return false. + + + + The example command above for Unix avoids overwriting a pre-existing archive + by including a separate test step. On some Unix platforms, cp has switches such as that can be used to do the same thing less verbosely, but you should not rely on these without verifying that -- 2.25.1 --SLDf9lqlvOQaIe6s--