From 39969e2a1e4d7f5a37f3ef37d53bbfe171e7d77a Mon Sep 17 00:00:00 2001 From: Stephen Frost Date: Wed, 6 Apr 2022 14:41:03 -0400 Subject: Remove exclusive backup mode Exclusive-mode backups have been deprecated since 9.6 (when non-exclusive backups were introduced) due to the issues they can cause should the system crash while one is running and generally because non-exclusive provides a much better interface. Further, exclusive backup mode wasn't really being tested (nor was most of the related code- like being able to log in just to stop an exclusive backup and the bits of the state machine related to that) and having to possibly deal with an exclusive backup and the backup_label file existing during pg_basebackup, pg_rewind, etc, added other complexities that we are better off without. This patch removes the exclusive backup mode, the various special cases for dealing with it, and greatly simplifies the online backup code and documentation. Authors: David Steele, Nathan Bossart Reviewed-by: Chapman Flack Discussion: https://postgr.es/m/ac7339ca-3718-3c93-929f-99e725d1172c@pgmasters.net https://postgr.es/m/CAHg+QDfiM+WU61tF6=nPZocMZvHDzCK47Kneyb0ZRULYzV5sKQ@mail.gmail.com --- src/bin/pg_basebackup/t/010_pg_basebackup.pl | 4 ++++ src/bin/pg_ctl/pg_ctl.c | 30 ---------------------------- src/bin/pg_rewind/filemap.c | 6 +++--- 3 files changed, 7 insertions(+), 33 deletions(-) (limited to 'src/bin') diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index 5ba84c22509..7309ebddea6 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -247,6 +247,10 @@ isnt(slurp_file("$tempdir/backup/backup_label"), 'DONOTCOPY', 'existing backup_label not copied'); rmtree("$tempdir/backup"); +# Now delete the bogus backup_label file since it will interfere with startup +unlink("$pgdata/backup_label") + or BAIL_OUT("unable to unlink $pgdata/backup_label"); + $node->command_ok( [ @pg_basebackup_defs, '-D', diff --git a/src/bin/pg_ctl/pg_ctl.c b/src/bin/pg_ctl/pg_ctl.c index 3c182c97d47..3a9092a16a6 100644 --- a/src/bin/pg_ctl/pg_ctl.c +++ b/src/bin/pg_ctl/pg_ctl.c @@ -1025,7 +1025,6 @@ static void do_stop(void) { pgpid_t pid; - struct stat statbuf; pid = get_pgpid(false); @@ -1058,20 +1057,6 @@ do_stop(void) } else { - /* - * If backup_label exists, an online backup is running. Warn the user - * that smart shutdown will wait for it to finish. However, if the - * server is in archive recovery, we're recovering from an online - * backup instead of performing one. - */ - if (shutdown_mode == SMART_MODE && - stat(backup_file, &statbuf) == 0 && - get_control_dbstate() != DB_IN_ARCHIVE_RECOVERY) - { - print_msg(_("WARNING: online backup mode is active\n" - "Shutdown will not complete until pg_stop_backup() is called.\n\n")); - } - print_msg(_("waiting for server to shut down...")); if (!wait_for_postmaster_stop()) @@ -1099,7 +1084,6 @@ static void do_restart(void) { pgpid_t pid; - struct stat statbuf; pid = get_pgpid(false); @@ -1134,20 +1118,6 @@ do_restart(void) exit(1); } - /* - * If backup_label exists, an online backup is running. Warn the user - * that smart shutdown will wait for it to finish. However, if the - * server is in archive recovery, we're recovering from an online - * backup instead of performing one. - */ - if (shutdown_mode == SMART_MODE && - stat(backup_file, &statbuf) == 0 && - get_control_dbstate() != DB_IN_ARCHIVE_RECOVERY) - { - print_msg(_("WARNING: online backup mode is active\n" - "Shutdown will not complete until pg_stop_backup() is called.\n\n")); - } - print_msg(_("waiting for server to shut down...")); /* always wait for restart */ diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c index 7211090f471..fb52debf7a6 100644 --- a/src/bin/pg_rewind/filemap.c +++ b/src/bin/pg_rewind/filemap.c @@ -140,9 +140,9 @@ static const struct exclude_list_item excludeFiles[] = {"pg_internal.init", true}, /* defined as RELCACHE_INIT_FILENAME */ /* - * If there's a backup_label or tablespace_map file, it belongs to a - * backup started by the user with pg_start_backup(). It is *not* correct - * for this backup. Our backup_label is written later on separately. + * If there is a backup_label or tablespace_map file, it indicates that + * a recovery failed and this cluster probably can't be rewound, but + * exclude them anyway if they are found. */ {"backup_label", false}, /* defined as BACKUP_LABEL_FILE */ {"tablespace_map", false}, /* defined as TABLESPACE_MAP */ -- cgit v1.2.3