pg_combinebackup copies stale tablespace_map, overriding -T on recovery

From: Zhijie Hou <houzhijie22(at)gmail(dot)com>
To: "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: pg_combinebackup copies stale tablespace_map, overriding -T on recovery
Date: 2026-12-06 16:02:22
Message-ID: e3aa1aa7-49e5-4082-85c3-f138152b37e5@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

While testing pg_combinebackup, I noticed that
process_directory_recursively() skips backup_label and backup_manifest,
but does not skip tablespace_map.

When combining unpacked tar-format (-Ft) or server-side backups on a
cluster with user-defined tablespaces, pg_combinebackup creates the
relocated symlinks under pg_tblspc/ according to -T, yet also copies the
stale tablespace_map from base.tar into the output directory. On
startup, recovery reads tablespace_map and overwrites those pg_tblspc/
symlinks with the source server's original tablespace paths, ignoring -T
(and risking corruption of the live primary's tablespace if started on
the same host).

Attached is a patch to skip tablespace_map alongside backup_label and
backup_manifest, matching basebackup.c and pg_rewind. Since
pg_combinebackup was introduced in v17, this affects v17 through master.

--
Best Regards,
Zhijie Hou

Attachment Content-Type Size
v1-0001-pg_combinebackup-Do-not-copy-tablespace_map-into-.patch text/plain 6.1 KB

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Banck 2026-12-06 16:09:25 Re: reltuples kept decreasing with each autovacuum run Re: BUG #18773
Previous Message Dave Sharpe 2026-12-06 15:46:26 [PATCH] Round fractional Julian days to the nearest microsecond