Exclude pg_internal.init from BASE_BACKUP
authorSimon Riggs <simon@2ndQuadrant.com>
Tue, 7 Nov 2017 17:28:35 +0000 (12:28 -0500)
committerSimon Riggs <simon@2ndQuadrant.com>
Tue, 7 Nov 2017 17:28:35 +0000 (12:28 -0500)
Add docs to explain this for other backup mechanisms

Author: David Steele <david@pgmasters.net>
Reviewed-by: Petr Jelinek <petr.jelinek@2ndQuadrant.com> et al
doc/src/sgml/backup.sgml
doc/src/sgml/protocol.sgml
src/backend/replication/basebackup.c
src/backend/utils/cache/relcache.c
src/bin/pg_basebackup/t/010_pg_basebackup.pl
src/include/utils/relcache.h

index dd9c1bff5b38cae39e977cb3a6816f241fdd876a..fa3a7016312826cf94673026404115e38bf0d048 100644 (file)
@@ -1129,6 +1129,12 @@ SELECT pg_stop_backup();
     the directories will be recreated as needed.
    </para>
 
+   <para>
+    <filename>pg_internal.init</filename> files can be omitted from the
+    backup whenever a file of that name is found.  These files contain
+    relation cache data that is always rebuilt when recovering.
+   </para>
+
    <para>
     The backup label
     file includes the label string you gave to <function>pg_start_backup</function>,
index 15108baf714cf55f80faf64785d01c977763ec12..f82affd0c58845ba3ead341f71b42300bf48bb71 100644 (file)
@@ -2499,6 +2499,11 @@ The commands accepted in walsender mode are:
          <filename>postmaster.opts</filename>
         </para>
        </listitem>
+       <listitem>
+        <para>
+         <filename>pg_internal.init (found in multiple directories)</>
+        </para>
+       </listitem>
        <listitem>
         <para>
          Various temporary files and directories created during the operation
index 75029b0def9911295b523161131edf8ce6769db7..1411c14e9283e9330cae125578f8b89e3d7bff7b 100644 (file)
@@ -36,6 +36,7 @@
 #include "utils/builtins.h"
 #include "utils/elog.h"
 #include "utils/ps_status.h"
+#include "utils/relcache.h"
 #include "utils/timestamp.h"
 
 
@@ -151,6 +152,9 @@ static const char *excludeFiles[] =
        /* Skip current log file temporary file */
        LOG_METAINFO_DATAFILE_TMP,
 
+       /* Skip relation cache because it is rebuilt on startup */
+       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
index b8e37809b0507bb5978bce2d01f446420bf081d5..5015719915b216f453d50fcf544af23396e46cbe 100644 (file)
 #include "utils/tqual.h"
 
 
-/*
- *             name of relcache init file(s), used to speed up backend startup
- */
-#define RELCACHE_INIT_FILENAME "pg_internal.init"
-
 #define RELCACHE_INIT_FILEMAGIC                0x573266        /* version ID value */
 
 /*
index 6a8be09f4cd9a6e208d28a724239776d8abcb3ce..cdf4f5be37a1901bbebfcfdfbf0d4381d3902faa 100644 (file)
@@ -4,7 +4,7 @@ use Cwd;
 use Config;
 use PostgresNode;
 use TestLib;
-use Test::More tests => 78;
+use Test::More tests => 79;
 
 program_help_ok('pg_basebackup');
 program_version_ok('pg_basebackup');
@@ -61,6 +61,11 @@ foreach my $filename (
        close $file;
 }
 
+# Connect to a database to create global/pg_internal.init.  If this is removed
+# the test to ensure global/pg_internal.init is not copied will return a false
+# positive.
+$node->safe_psql('postgres', 'SELECT 1;');
+
 $node->command_ok([ 'pg_basebackup', '-D', "$tempdir/backup", '-X', 'none' ],
        'pg_basebackup runs');
 ok(-f "$tempdir/backup/PG_VERSION", 'backup was created');
@@ -84,7 +89,8 @@ 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)
+       qw(postgresql.auto.conf.tmp postmaster.opts postmaster.pid tablespace_map current_logfiles.tmp
+               global/pg_internal.init)
   )
 {
        ok(!-f "$tempdir/backup/$filename", "$filename not copied");
index 3c53cefe4b4f440c68930c4875d190ac38692563..29c6d9bae3759b775f153f4df9d02cdac4ce24db 100644 (file)
 #include "nodes/bitmapset.h"
 
 
+/*
+ * Name of relcache init file(s), used to speed up backend startup
+ */
+#define RELCACHE_INIT_FILENAME "pg_internal.init"
+
 typedef struct RelationData *Relation;
 
 /* ----------------