Skip to content

Add a redacted physical backup format - #118

Draft
x4m wants to merge 3 commits into
MDB_18_6_prestablefrom
redacted-basebackup
Draft

x4m wants to merge 3 commits into
MDB_18_6_prestablefrom
redacted-basebackup

Conversation

@x4m

@x4m x4m commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add the default-off ycmdb.redacted_physical_backup rollout gate
  • when enabled, allow existing mdb_admin members without full replication
    privileges to take a redacted physical backup and consume its WAL stream
  • omit pg_authid, pg_statistic, and pg_statistic_ext_data storage
  • replace WAL records modifying those catalogs with equal-length XLOG_NOOP
    records, preserving LSNs and the remaining stream
  • permanently disable the format after a redacted-catalog storage rewrite

The service creates a persistent physical slot and restores the omitted
catalogs from trusted storage before starting PostgreSQL from the backup.
The GUC is latched when a replication connection starts, so rollout or
rollback requires reconnecting the client. Incremental backups and embedded
WAL are intentionally outside format version 1.

Validation

  • make -j12 -s
  • focused redacted-backup TAP test: 71/71
  • complete src/bin/pg_basebackup TAP suite: 386/386
  • actual recovery and replay from the redacted backup and WAL
  • continued streaming after promotion and a WAL record crossing a segment
    boundary
  • source-WAL and redacted-WAL checks for ordinary and extended statistics

@x4m
x4m force-pushed the redacted-basebackup branch from 1fbee2f to e67410f Compare September 4, 2026 10:36
@reshke
reshke changed the base branch from MDB_18_STABLE to MDB_18_6_prestable September 4, 2026 10:44
CPG service users need a physical backup and continuing WAL stream
without copying cluster-wide role data or planner statistics.  Existing
replication privileges expose the complete data directory and WAL.

Add ycmdb.redacted_physical_backup, disabled by default.  When enabled,
allow mdb_admin members without full replication privileges to use a
restricted subset of the physical replication protocol.  Omit pg_authid,
pg_statistic, and pg_statistic_ext_data storage from base backups and
replace WAL records modifying that storage with equal-length XLOG_NOOP
records.  Preserving record lengths leaves LSNs and the rest of the
stream unchanged.

The format relies on the bootstrap relfilenumbers of the omitted
catalogs.  Interlock restricted senders with catalog rewrites and
permanently disable the format after the first rewrite attempt.
Replicate the disablement in a versioned XLOG_NOOP payload.  Close a
restricted sender after an error so that transaction cleanup cannot
release the interlock and then reuse the connection.

Require streamed WAL, reject incremental backups, and disallow
restricted senders during recovery.  Exercise the protocol restrictions,
omitted files, recovery, continued streaming, and rewrite disablement in
TAP.
@reshke
reshke force-pushed the redacted-basebackup branch from e67410f to 6701930 Compare September 4, 2026 10:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant