pgsql: Remove pg_backup_start_callback and reuse similar code

From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Remove pg_backup_start_callback and reuse similar code
Date: 2022-10-19 08:45:33
Message-ID: E1ol4hg-0032Yb-MF@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Remove pg_backup_start_callback and reuse similar code

We had two copies of almost identical logic to revert shared memory
state when a running backup aborts; we can remove
pg_backup_start_callback if we adapt do_pg_abort_backup so that it can
be used for this purpose too.

However, in order for this to work, we have to repurpose the flag passed
to do_pg_abort_backup. It used to indicate whether to throw a warning
(and the only caller always passed true). It now indicates whether the
callback is being called at start time (in which case the session backup
state is known not to have been set to RUNNING yet, so action is always
taken) or shmem time (in which case action is only taken if the session
backup state is RUNNING). Thus the meaning of the flag is no longer
superfluous, but it's actually quite critical to get right. I (Álvaro)
chose to change the polarity and the code flow re. the flag from what
Bharath submitted, for coding clarity.

Co-authored-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/20221013111330.564fk5tkwe3ha77l%40alvherre.pgsql

Branch
------
master

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

Modified Files
--------------
src/backend/access/transam/xlog.c | 81 +++++++++++++++++----------------------
1 file changed, 35 insertions(+), 46 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Thomas Munro 2022-10-19 10:06:40 pgsql: Track LLVM 15 changes.
Previous Message Michael Paquier 2022-10-19 05:07:45 pgsql: Rework shutdown callback of archiver modules