Skip to content

pg::wal::receive: make lsn_to_timeline public - #21

Merged
achudnovskij merged 1 commit into
mainfrom
expose-lsn-to-timeline
Jul 17, 2026
Merged

pg::wal::receive: make lsn_to_timeline public#21
achudnovskij merged 1 commit into
mainfrom
expose-lsn-to-timeline

Conversation

@achudnovskij

Copy link
Copy Markdown
Contributor

What

Make the existing lsn_to_timeline in pg::wal::receive pub so external WAL-processing tools can reuse it.

pub fn lsn_to_timeline(content: &[u8], lsn: u64, file_timeline: u32) -> u32

Why

Resolving which timeline owns a resume LSN by walking a TIMELINE_HISTORY response is a standard step for anything that streams replication and can resume behind a timeline fork. lsn_to_timeline already implements it (mirrors wal-g's LSNToTimeLine), but it was private, so the wal-listener synchronous receiver had to duplicate it byte-for-byte. This exposes the single implementation and lets that copy be deleted.

Follow-up to #19 ("Expose replication + object-storage primitives for building WAL-processing tools").

Notes

  • No behavior change — pure visibility (fnpub fn) plus a doc note.
  • The existing lsn_to_timeline_walks_history unit test still covers it.
  • The module path is already public (pub mod pgpub mod walpub mod receive), so it's reachable as walrus::pg::wal::receive::lsn_to_timeline.

🤖 Generated with Claude Code

Comment thread src/pg/wal/receive.rs Outdated
@achudnovskij
achudnovskij force-pushed the expose-lsn-to-timeline branch 2 times, most recently from fd0fda6 to ea6a3d5 Compare July 16, 2026 22:26
@achudnovskij
achudnovskij marked this pull request as ready for review July 16, 2026 22:26
External WAL-processing tools that stream replication (e.g. the wal-listener
synchronous receiver) need to resolve which timeline owns a resume LSN by
walking a `TIMELINE_HISTORY`
@achudnovskij
achudnovskij force-pushed the expose-lsn-to-timeline branch from ea6a3d5 to da7ecab Compare July 16, 2026 22:40
@achudnovskij
achudnovskij merged commit d234c73 into main Jul 17, 2026
93 checks passed
@achudnovskij
achudnovskij deleted the expose-lsn-to-timeline branch July 17, 2026 00:09
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.

2 participants