diff options
author | Robert Haas <rhaas@postgresql.org> | 2019-12-19 09:06:54 -0500 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2019-12-19 09:06:54 -0500 |
commit | 303640199d0436c5e7acdf50b837a027b5726594 (patch) | |
tree | 7e29adeaf572d6bb1ba0d44649b86f64520e109c /src/include/access/xlog.h | |
parent | e975c1a6026adb9e248a408fe3ca2629bc8c0084 (diff) | |
download | postgresql-303640199d0436c5e7acdf50b837a027b5726594.tar.gz postgresql-303640199d0436c5e7acdf50b837a027b5726594.zip |
Fix minor problems with non-exclusive backup cleanup.
The previous coding imagined that it could call before_shmem_exit()
when a non-exclusive backup began and then remove the previously-added
handler by calling cancel_before_shmem_exit() when that backup
ended. However, this only works provided that nothing else in the
system has registered a before_shmem_exit() hook in the interim,
because cancel_before_shmem_exit() is documented to remove a callback
only if it is the latest callback registered. It also only works
if nothing can ERROR out between the time that sessionBackupState
is reset and the time that cancel_before_shmem_exit(), which doesn't
seem to be strictly true.
To fix, leave the handler installed for the lifetime of the session,
arrange to install it just once, and teach it to quietly do nothing if
there isn't a non-exclusive backup in process.
This is a bug, but for now I'm not going to back-patch, because the
consequences are minor. It's possible to cause a spurious warning
to be generated, but that doesn't really matter. It's also possible
to trigger an assertion failure, but production builds shouldn't
have assertions enabled.
Patch by me, reviewed by Kyotaro Horiguchi, Michael Paquier (who
preferred a different approach, but got outvoted), Fujii Masao,
and Tom Lane, and with comments by various others.
Discussion: http://postgr.es/m/CA+TgmobMjnyBfNhGTKQEDbqXYE3_rXWpc4CM63fhyerNCes3mA@mail.gmail.com
Diffstat (limited to 'src/include/access/xlog.h')
-rw-r--r-- | src/include/access/xlog.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 9b588c87a52..3fea1993bc0 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -349,7 +349,8 @@ extern XLogRecPtr do_pg_start_backup(const char *backupidstr, bool fast, bool needtblspcmapfile); extern XLogRecPtr do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p); -extern void do_pg_abort_backup(void); +extern void do_pg_abort_backup(int code, Datum arg); +extern void register_persistent_abort_backup_handler(void); extern SessionBackupState get_backup_status(void); /* File path names (all relative to $PGDATA) */ |