aboutsummaryrefslogtreecommitdiff
path: root/src/backend/backup/basebackup_incremental.c
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2024-03-04 13:33:12 -0500
committerRobert Haas <rhaas@postgresql.org>2024-03-04 13:33:28 -0500
commitd75c4027b6f260f2045b162017567aeeb909b056 (patch)
tree35488e90b82274595b76e1484b2b582d7b779cba /src/backend/backup/basebackup_incremental.c
parentcb6945dc8061d03e6ec670a6856228f12e94264c (diff)
downloadpostgresql-d75c4027b6f260f2045b162017567aeeb909b056.tar.gz
postgresql-d75c4027b6f260f2045b162017567aeeb909b056.zip
Fix incremental backup interaction with XLOG_DBASE_CREATE_FILE_COPY.
After XLOG_DBASE_CREATE_FILE_COPY, a correct incremental backup needs to copy in full everything with the database and tablespace OID mentioned in that record; but that record doesn't specifically mention the blocks, or even the relfilenumbers, of the affected relations. As a result, we were failing to copy data that we should have copied. To fix, enter the DB OID and tablespace OID into the block reference table with relfilenumber 0 and limit block 0; and treat that as a limit block of 0 for every relfilenumber whose DB OID and tablespace OID match. Also, add a test case. Patch by me, reviewed by Noah Misch. Discussion: http://postgr.es/m/CA+Tgmob0xa=ByvGLMdAgkUZyVQE=r4nyYZ_VEa40FCfEDFnTKA@mail.gmail.com
Diffstat (limited to 'src/backend/backup/basebackup_incremental.c')
-rw-r--r--src/backend/backup/basebackup_incremental.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/backend/backup/basebackup_incremental.c b/src/backend/backup/basebackup_incremental.c
index 18c78adda26..a8f2e72e7b1 100644
--- a/src/backend/backup/basebackup_incremental.c
+++ b/src/backend/backup/basebackup_incremental.c
@@ -777,9 +777,25 @@ GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path,
return BACK_UP_FILE_FULLY;
}
- /* Look up the block reference table entry. */
+ /*
+ * Look up the special block reference table entry for the database as
+ * a whole.
+ */
rlocator.spcOid = spcoid;
rlocator.dbOid = dboid;
+ rlocator.relNumber = 0;
+ if (BlockRefTableGetEntry(ib->brtab, &rlocator, MAIN_FORKNUM,
+ &limit_block) != NULL)
+ {
+ /*
+ * According to the WAL summary, this database OID/tablespace OID
+ * pairing has been created since the previous backup. So, everything
+ * in it must be backed up fully.
+ */
+ return BACK_UP_FILE_FULLY;
+ }
+
+ /* Look up the block reference table entry for this relfilenode. */
rlocator.relNumber = relfilenumber;
brtentry = BlockRefTableGetEntry(ib->brtab, &rlocator, forknum,
&limit_block);