Skip to content

Add recovery target reached hook with stop-boundary metadata PG16#64

Closed
GremSnoort wants to merge 2 commits into
patches16from
recovery-target-reached-hook-pg16
Closed

Add recovery target reached hook with stop-boundary metadata PG16#64
GremSnoort wants to merge 2 commits into
patches16from
recovery-target-reached-hook-pg16

Conversation

@GremSnoort
Copy link
Copy Markdown
Contributor

Summary

Add a new RecoveryTargetReachedHook that is invoked after PostgreSQL has determined that a recovery target has been reached, but before recovery_target_action is applied.

The hook receives explicit stop-boundary metadata via RecoveryTargetReachedInfo, including:

  • target type
  • stop semantics (before / after)
  • stop metadata (xid, time, LSN, name)
  • ReadRecPtr / EndRecPtr for the record at the stop boundary

Problem

PostgreSQL can reach a recovery target before an extension with custom replay/finalization logic has fully synchronized its own visible state to that same stop boundary.

In such cases, PostgreSQL already considers the target reached, but the extension-visible state may still lag behind the actual recovery stop point. This makes it difficult for extensions to guarantee correct target-point visibility semantics using only generic replay-progress information.

Motivation

Extensions with custom replay/finalization logic may need to synchronize their internal state against the actual recovery stop boundary before PostgreSQL exposes the target-reached state.

A generic replay-progress pointer is not always sufficient for this, especially for target types where extension-visible state must match the precise stop boundary semantics.

Changes

  • add RecoveryTargetReachedInfo to carry recovery stop-boundary metadata
  • add RecoveryTargetReachedHookType
  • add RecoveryTargetReachedHook
  • invoke the hook in PerformWalRecovery() after reachedRecoveryTarget and before recovery_target_action is applied

Result

This gives extensions an explicit integration point for target-boundary synchronization/finalization without changing normal replay flow.

Issue

Closes: orioledb/orioledb#820

Add a new RecoveryTargetReachedHook that is invoked after PostgreSQL
reaches a recovery target and before recovery_target_action is applied.

The hook receives a RecoveryTargetReachedInfo structure with the
ReadRecPtr/EndRecPtr of the WAL record at the recovery stop boundary.

This gives extensions an explicit recovery stop-boundary context for
synchronizing or finalizing custom replay state before PostgreSQL
exposes the target-reached state.
@pashkinelfe
Copy link
Copy Markdown
Contributor

same as #63

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.

Fix recovery/003_recovery_targets PostgreSQL test

2 participants