pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathan@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add built-in ERROR handling for archive callbacks.
Date: Wed, 03 Apr 2024 03:30:59 +0000
Message-ID: <E1rrrL0-000EEy-LO@gemulon.postgresql.org> (raw)

Add built-in ERROR handling for archive callbacks.

Presently, the archiver process restarts when an archive callback
ERRORs.  To avoid this, archive module authors can use sigsetjmp(),
manage a memory context, etc., but that requires a lot of extra
code that will likely look roughly the same between modules.  This
commit adds basic archive callback ERROR handling to pgarch.c so
that module authors won't ordinarily need to worry about this.
While this built-in handler attempts to clean up anything that an
archive module could conceivably have left behind, it is possible
that some modules are doing unexpected things that require
additional cleanup.  Module authors should be sure to do any extra
required cleanup in a PG_CATCH block within the archiving callback.

The archiving callback is now called in a short-lived memory
context that the archiver process resets between invocations.  If a
module requires longer-lived storage, it must maintain its own
memory context.

Thanks to these changes, the basic_archive module can be greatly
simplified.

Suggested-by: Andres Freund
Reviewed-by: Andres Freund, Yong Li
Discussion: https://postgr.es/m/20230217215624.GA3131134%40nathanxps13

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/c627d944e6c2620fb3b28f2e4b27e19212f84045

Modified Files
--------------
contrib/basic_archive/basic_archive.c | 134 ++--------------------------------
doc/src/sgml/archive-modules.sgml     |  11 ++-
src/backend/archive/shell_archive.c   |   5 --
src/backend/postmaster/pgarch.c       |  93 ++++++++++++++++++++++-
4 files changed, 107 insertions(+), 136 deletions(-)



Message-ID: <E1rrrL0-000EEy-LO@gemulon.postgresql.org>
Permalink:  ../E1rrrL0-000EEy-LO@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1rrrL0-000EEy-LO@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: nathan@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add built-in ERROR handling for archive callbacks.
  In-Reply-To: <E1rrrL0-000EEy-LO@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox