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 1nDaqG-0001Cz-WA for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Jan 2022 23:39:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nDaqF-0001Kh-Q7 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Jan 2022 23:39:43 +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 1nDaqF-0001KK-FH for pgsql-hackers@lists.postgresql.org; Fri, 28 Jan 2022 23:39:43 +0000 Received: from mail-pg1-x52a.google.com ([2607:f8b0:4864:20::52a]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nDaqC-0008I4-2b for pgsql-hackers@postgresql.org; Fri, 28 Jan 2022 23:39:43 +0000 Received: by mail-pg1-x52a.google.com with SMTP id t32so6583830pgm.7 for ; Fri, 28 Jan 2022 15:39:39 -0800 (PST) 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=pcWi/c6nzvOZOLFtJMz4rdcd6RQU/ptymXK1tbbYmpA=; b=E+nXe9bBHOPn0mGQnTcnFgRdNyY95unDmhkeIm128vio7L7rueDEHzBz/QlI4c65mh TZn4XXsxbWtZ7ZdeNsUvzKAEogXk+VLC6gFEknk4qtL2zSpy4QnfKj7ElXXhvRIqtnez qWoxlCCTJ5SFrBhdQzf+19+Md4DeYmiCHt4PZYT/lQ1D7hiVJVvRlVjzQVEUwU9Oo5ZU yqJLddhR3HiH0qW0i59R89Dh2YajVc0T30NrXdrUh6tEOLKtP+/ADgoVxvgFCU/2HnPY 0NOrWNfG1oz4ks3NuOGtqFKhczhwe0D6gnFeQvmhXNrV694J39s4piCRQQm3ZH7RY6ms S+lQ== 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=pcWi/c6nzvOZOLFtJMz4rdcd6RQU/ptymXK1tbbYmpA=; b=vfN7xyzYoIAwY9XYtk2QurWZQOUP6mjmoKO4J+7t0HekCQgr+WSrFx2T9Og2SEN/+p hdEV1nBczIRgv9CHHC2L/C9XXsfArig0ktW3DF9U9VOHF+WEcNLYX66/AoURjxu0pgNY QTt5zg9tv4jmkD3dFNe4oTdzT8JxAyRG+zsneVt6Yjrj101qRck+KVQxvMJ0/aqow7wR s2jDH1tO8Phpj+Po2Nq0v+cQ2NLA4+oFnL7Gi1aE/6oRVbmZYa1PUO6WdSb8tZrmuSKN Ad0uSEx2LYYPz1FwUXS8F+6UgaDDfC/iiMDPYRl3dFR02dSfBFiFuUxCabk8HWPz9D8d xw4w== X-Gm-Message-State: AOAM533pgPY/adkEqB13gzKOXYyxdnONbnJei76dWQgp1P0KV4CGc7T6 yuqEo0T+y5tPIDqp92Dm8bQ= X-Google-Smtp-Source: ABdhPJxpxO00rhGRePjcjZt7m2dr4nQDzKXPdPsqinykyyosulFAlOZZuVMAl7fUYoLIZzFj56Yx5Q== X-Received: by 2002:a63:1c10:: with SMTP id c16mr8315933pgc.275.1643413177867; Fri, 28 Jan 2022 15:39:37 -0800 (PST) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id rj1sm3580815pjb.49.2022.01.28.15.39.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Jan 2022 15:39:37 -0800 (PST) Date: Fri, 28 Jan 2022 15:39:35 -0800 From: Nathan Bossart To: Robert Haas Cc: "Bossart, Nathan" , David Steele , Fujii Masao , "pgsql-hackers@postgresql.org" , Michael Paquier , Magnus Hagander , Stephen Frost Subject: Re: archive modules Message-ID: <20220128233935.GA6472@nathanxps13> References: <4c01ce36-fbed-104a-ef9c-6046343dc845@pgmasters.net> <316CAF77-A0AC-49AE-A175-1C1ECF6C1981@amazon.com> <71E7A5D1-E418-4516-A21D-BD838BA759CE@amazon.com> <0CF39706-6952-49B1-987D-F012CDF5EEC4@amazon.com> <90D3CEE4-00C1-450C-80B1-88B69D9318DE@amazon.com> <3842CF04-528B-42A5-A12D-BA3970EF1E53@amazon.com> <5D92CC59-47C8-4463-9150-44033DDDD0D8@amazon.com> <20220128200138.GA3398@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jan 28, 2022 at 03:20:41PM -0500, Robert Haas wrote: > On Fri, Jan 28, 2022 at 3:01 PM Nathan Bossart wrote: >> I discussed the two main deficiencies I'm aware of with basic_archive >> earlier [0]. The first one is the issue with "incovenient" server crashes >> (mentioned below). > > Seems easy enough to rectify, if it's just a matter of silently-succeed-if-same. Yes. >> The second is that there is no handling for multiple >> servers writing to the same location since the temporary file is always >> named "archtemp." I thought about a few ways to pick a unique file name >> (or at least one that is _probably_ unique), but that began adding a lot of >> complexity for something I intended as a test module. I can spend some >> more time on this if you think it's worth fixing for a contrib module. > > Well, my first thought was to wonder whether we even care about that > scenario, but I guess we probably do, at least a little bit. > > How about: > > 1. Name temporary files like > archive_temp.${FINAL_NAME}.${PID}.${SOME_RANDOM_NUMBER}. Create them > with O_EXCL. If it fails, die. > > 2. Try not to leave files like this behind, perhaps installing an > on_proc_exit callback or similar, but accept that crashes and unlink() > failures will make it inevitable in some cases. > > 3. Document that crashes or other strange failure cases may leave > archive_temp.* files behind in the archive directory, and recommend > that users remove them before restarting the database after a crash > (or, with caution, removing them while the database is running if the > user is sure that the files are old and unrelated to any archiving > still in progress). > > I'm not arguing that this is exactly the right idea. But I am arguing > that it shouldn't take a ton of engineering to come up with something > reasonable here. This is roughly what I had in mind. I'll give it a try. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com