From 1b3d95607afeb4f1fa98c3ea006f310ab68252f7 Mon Sep 17 00:00:00 2001 From: David Steele Date: Fri, 27 Sep 2019 14:49:07 -0400 Subject: [PATCH] Ignore recovery/standby signal files in pg_basebackup. Restoring these files could cause surprising behaviors so it seems best to let the restore process create them when needed. --- src/backend/replication/basebackup.c | 7 +++++++ src/bin/pg_basebackup/t/010_pg_basebackup.pl | 14 +++++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c index d0f210de8c..65075b1770 100644 --- a/src/backend/replication/basebackup.c +++ b/src/backend/replication/basebackup.c @@ -183,6 +183,13 @@ static const char *const excludeFiles[] = /* Skip relation cache because it is rebuilt on startup */ RELCACHE_INIT_FILENAME, + /* + * Skip recovery/standby signal files. These files should be created after + * restore if they are required. + */ + RECOVERY_SIGNAL_FILE, + STANDBY_SIGNAL_FILE, + /* * 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 diff --git a/src/bin/pg_basebackup/t/010_pg_basebackup.pl b/src/bin/pg_basebackup/t/010_pg_basebackup.pl index b7d36b65dd..6bccaef15a 100644 --- a/src/bin/pg_basebackup/t/010_pg_basebackup.pl +++ b/src/bin/pg_basebackup/t/010_pg_basebackup.pl @@ -6,7 +6,7 @@ use File::Basename qw(basename dirname); use File::Path qw(rmtree); use PostgresNode; use TestLib; -use Test::More tests => 106; +use Test::More tests => 108; program_help_ok('pg_basebackup'); program_version_ok('pg_basebackup'); @@ -65,7 +65,8 @@ $node->restart; # Write some files to test that they are not copied. foreach my $filename ( - qw(backup_label tablespace_map postgresql.auto.conf.tmp current_logfiles.tmp) + qw(backup_label tablespace_map postgresql.auto.conf.tmp current_logfiles.tmp + recovery.signal standby.signal) ) { open my $file, '>>', "$pgdata/$filename"; @@ -135,11 +136,18 @@ foreach my $dirname ( # These files should not be copied. foreach my $filename ( qw(postgresql.auto.conf.tmp postmaster.opts postmaster.pid tablespace_map current_logfiles.tmp - global/pg_internal.init)) + global/pg_internal.init recovery.signal standby.signal)) { ok(!-f "$tempdir/backup/$filename", "$filename not copied"); } +# Remove recovery/standby signal files so they don't break further testing. +foreach my $filename (qw(recovery.signal standby.signal)) +{ + unlink("$pgdata/$filename") + or BAIL_OUT("unable to unlink $pgdata/backup/$filename"); +} + # Unlogged relation forks other than init should not be copied ok(-f "$tempdir/backup/${baseUnloggedPath}_init", 'unlogged init fork in backup'); -- 2.20.1 (Apple Git-117)