pgsql: Fix minor problems with non-exclusive backup cleanup. - Mailing list pgsql-committers

From Robert Haas
Subject pgsql: Fix minor problems with non-exclusive backup cleanup.
Date
Msg-id E1k3kMF-0002w0-Ai@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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 was originally committed to master as
303640199d0436c5e7acdf50b837a027b5726594, but I did not back-patch
at the time because the consequences were minor. However, now
there's been a second report of this causing trouble with a slightly
different test case than the one I reported originally, so now
I'm back-patching as far as v11 where JIT was introduced.

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. New problem
report from Bharath Rupireddy.

Discussion: http://postgr.es/m/CA+TgmobMjnyBfNhGTKQEDbqXYE3_rXWpc4CM63fhyerNCes3mA@mail.gmail.com
Discussion: http://postgr.es/m/CALj2ACWk7j4F2v2fxxYfrroOF=AdFNPr1WsV+AGtHAFQOqm_pw@mail.gmail.com

Branch
------
REL_11_STABLE

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

Modified Files
--------------
src/backend/access/transam/xlog.c      | 32 +++++++++++++++++++++++++++++---
src/backend/access/transam/xlogfuncs.c | 17 ++---------------
src/backend/replication/basebackup.c   | 16 ++--------------
src/include/access/xlog.h              |  3 ++-
4 files changed, 35 insertions(+), 33 deletions(-)


pgsql-committers by date:

Previous
From: Bruce Momjian
Date:
Subject: pgsql: doc: clarify "state" table reference in tutorial
Next
From: Tom Lane
Date:
Subject: Re: pgsql: Fix minor problems with non-exclusive backup cleanup.