Skip to content

feat(pitr): support POSTGRES_RECOVERY_TARGET_TYPE=immediate#30

Closed
paulocsanz wants to merge 1 commit into
mainfrom
pc/pitr-type-immediate
Closed

feat(pitr): support POSTGRES_RECOVERY_TARGET_TYPE=immediate#30
paulocsanz wants to merge 1 commit into
mainfrom
pc/pitr-type-immediate

Conversation

@paulocsanz
Copy link
Copy Markdown
Collaborator

Summary

Mirror of the postgres-ssl change for the Patroni runner: support POSTGRES_RECOVERY_TARGET_TYPE=immediate for restoring brand-new clusters that have a base backup but no committed transactions to anchor recovery against.

  • config.rs: new pitr_target_immediate: bool from the env var.
  • patroni_runner.rs: configure_pitr_recovery writes recovery_target = 'immediate' (no value) when on the immediate branch. Precedence _TYPE=immediate > _XID > _TIME, matching postgres-ssl. Caller gate accepts any of the three.

Context

Pairs with postgres-ssl PR (#74) and the mono picker change. Restored services are postgres-ssl (per the existing patroni→ssl image swap in stageInitialPITRRestorePatch), so this change mostly covers the in-place HA-replay path that exists for symmetry.

Test plan

  • cargo check clean.
  • Manual: set POSTGRES_RECOVERY_TARGET_TYPE=immediate on an HA node with WAL_RECOVER_FROM_* — patroni-runner stages recovery_target = 'immediate' and postgres comes up promoted at base-backup consistency.
  • Manual: existing _TIME-only and _XID-over-_TIME paths still work (regression).

Add a third recovery target type for clusters where neither `_TIME` nor
`_XID` can anchor recovery. When `POSTGRES_RECOVERY_TARGET_TYPE` is
`immediate`, the patroni-runner writes `recovery_target = 'immediate'`
to postgresql.auto.conf so Postgres stops at end-of-base-backup
consistency without needing a target value.

Precedence: `_TYPE=immediate` > `_XID` > `_TIME`, matching postgres-ssl.
Existing `_TIME` and `_XID` paths are unchanged.
@paulocsanz
Copy link
Copy Markdown
Collaborator Author

Pivoting to a simpler approach: have the backup-watcher emit one transactional commit after each successful backup. New PR will follow.

@paulocsanz paulocsanz closed this May 11, 2026
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