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 1pSmGg-0000JR-80 for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 21:58:18 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pSmGf-0003BI-2y for pgsql-hackers@arkaria.postgresql.org; Thu, 16 Feb 2023 21:58:17 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pSmGe-00039b-Nm for pgsql-hackers@lists.postgresql.org; Thu, 16 Feb 2023 21:58:16 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pSmGb-00034u-Ml for pgsql-hackers@postgresql.org; Thu, 16 Feb 2023 21:58:15 +0000 Received: by mail-pj1-x1036.google.com with SMTP id nh19-20020a17090b365300b00233ceae8407so3548803pjb.3 for ; Thu, 16 Feb 2023 13:58:13 -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=k1u0SsZ2pEWg9QBSf6UxjHPT6qe3ed/OQra4Y2YYvAc=; b=cyVstPtnhywOmD/aegCWsc+HvrihAyYuE/bcRmQIT8sZN1/aaxRiJ55BtdPegzVhSM L7WC0tF5PxvyAROtlj1fWdM/M2XO2uBsX4hbPf+I5tf0yXWxpkN4cavxodRv0tWpyOSK DG02MvMCeCu5WQRWuoT7qf8tT9LwYT6muwGp8/ch0n6uBmgFWe577yyV4rFarL32mZRW 3JENQG8v6bPmUeLVHcFgnTm4BsxyMscrFiL+6cC1yUL0MBtTEa5Ggy/UTRJL8zY2a9Xz zKvaFH5aJuEI2PRGnvXXZEMhruMzLV8CicQapMjNYTYNOHlZllSavCj2NKJ+AqqLhLtX zZGA== 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=k1u0SsZ2pEWg9QBSf6UxjHPT6qe3ed/OQra4Y2YYvAc=; b=2rKm14NMm6BI87QBkMP4DMXNib/SMSfDIxNmSH/i8dJaf4RpoeXJRBqbapSq5Sddox agV4F+DQoi9JKKMZwN2iOOEgj506Qg6YNJPokryg/fedZEesfzGQHKylqgLnUGuOLDBe F9WfD9yNCetw+or7zBZyxampjQnXcTMQZs9uUuu9/X6Bd9BFYLt+oI+bfufJ3XDfhDC9 LoVMDpNsXdQNkZViyGfhs4F075zTJiVT+FErJCE1pyPqJUzZJD/d4sQMHyIDGqvN1Ux5 QaVVdoU5TlsHtNU8h2Z3zVlyH42WG0jDQ3fcqUBVcEAxxUA0KDrSAHbu5FcjNahl4b31 GQgg== X-Gm-Message-State: AO0yUKVk1SLcfhEQbXxmCGU/T+bK/kYhZ2P7SrGjmoPNYG4qStRtI4yu J1QHJeYEq8iEfBiYye00s4I= X-Google-Smtp-Source: AK7set9q95Mh/XolEZ4GhB06ELMjZJWYxx8hr6SsZqJpDXsRN4Y2sYwwASxQWIjqpgxK0GmVLcaN1A== X-Received: by 2002:a05:6a20:3094:b0:c7:6cb7:cfbd with SMTP id 20-20020a056a20309400b000c76cb7cfbdmr348031pzn.12.1676584692605; Thu, 16 Feb 2023 13:58:12 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id m192-20020a633fc9000000b004faf33e2758sm1654207pga.40.2023.02.16.13.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 13:58:11 -0800 (PST) Date: Thu, 16 Feb 2023 13:58:10 -0800 From: Nathan Bossart To: Andres Freund Cc: Robert Haas , Michael Paquier , pgsql-hackers@postgresql.org Subject: Re: recovery modules Message-ID: <20230216215810.GA2356244@nathanxps13> References: <20230213225647.GA1102783@nathanxps13> <20230213233733.dsiaxtbr5nvskq46@awork3.anarazel.de> <20230214005558.GA1145703@nathanxps13> <20230214010237.GA1187708@nathanxps13> <20230215184407.GA1481856@nathanxps13> <20230216192956.mhi6uiakchkolpki@awork3.anarazel.de> <20230216201512.GA2074541@nathanxps13> <20230216211754.7z2v5i7gh3xahikl@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230216211754.7z2v5i7gh3xahikl@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Thu, Feb 16, 2023 at 01:17:54PM -0800, Andres Freund wrote: > On 2023-02-16 12:15:12 -0800, Nathan Bossart wrote: >> On Thu, Feb 16, 2023 at 11:29:56AM -0800, Andres Freund wrote: >> > On 2023-02-15 10:44:07 -0800, Nathan Bossart wrote: >> >> @@ -144,10 +170,12 @@ basic_archive_configured(void) >> >> * Archives one file. >> >> */ >> >> static bool >> >> -basic_archive_file(const char *file, const char *path) >> >> +basic_archive_file(ArchiveModuleState *state, const char *file, const char *path) >> >> { >> >> sigjmp_buf local_sigjmp_buf; >> > >> > Not related the things changed here, but this should never have been pushed >> > down into individual archive modules. There's absolutely no way that we're >> > going to keep this up2date and working correctly in random archive >> > modules. And it would break if archive modules are ever called outside of >> > pgarch.c. >> >> Yeah. IIRC I did briefly try to avoid this, but the difficulty was that >> each module will have its own custom cleanup logic. > > It can use PG_TRY/CATCH for that, if the top-level sigsetjmp is in pgarch.c. > Or you could add a cleanup callback to the API, to be called after the > top-level cleanup in pgarch.c. Yeah, that seems workable. > I'm quite baffled by: > /* Close any files left open by copy_file() or compare_files() */ > AtEOSubXact_Files(false, InvalidSubTransactionId, InvalidSubTransactionId); > > in basic_archive_file(). It seems *really* off to call AtEOSubXact_Files() > completely outside the context of a transaction environment. And it only does > the thing you want because you pass parameters that aren't actually valid in > the normal use in AtEOSubXact_Files(). I really don't understand how that's > supposed to be ok. Hm. Should copy_file() and compare_files() have PG_FINALLY blocks that attempt to close the files instead? What would you recommend? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com