Skip to content

feat(sql): return the read pin from SHOW SNAPSHOT - #407

Closed
EnRaiha wants to merge 1 commit into
NodeDB-Lab:mainfrom
EnRaiha:pr/374-370-show-snapshot
Closed

EnRaiha wants to merge 1 commit into
NodeDB-Lab:mainfrom
EnRaiha:pr/374-370-show-snapshot

Conversation

@EnRaiha

@EnRaiha EnRaiha commented Oct 1, 2026

Copy link
Copy Markdown
Contributor

What

SHOW SNAPSHOT returns the read pin a multi-page reader needs.

A reader that pages with a fresh snapshot per page can land between two producer transactions and return a half-applied batch. It had no token to tell a complete page from an incomplete one, so a loader paging a 66k edge backfill could not detect a torn read and would act on partial data.

It returns the monotonic WAL sequence at the moment of the call, with the node id and the build version. The reason the pin is the sequence and not a timestamp is that a sequence orders writes, while a clock does not. Capture the pin once; a producer that records the same pin in its commit marker lets the reader decide whether the batch it paged is complete.

Not tenant-admin gated: it exposes no tenant data, and a reader needs the pin before it has paged anything.

Evidence

The test fails on main without this change. Proof: the test was copied onto a clean origin/main (bd8da7dc2) worktree and run there first.

  • cargo nextest run -p nodedb --test wire -E 'test(~show_snapshot_returns_the_wal_pin)' on a clean main: FAIL.
  • On this branch: pgwire_show_dispatch 19/19 pass, including show_snapshot_returns_the_wal_pin.
  • The test asserts the statement does not fall through to the session-parameter fallback, that snapshot_pin names the pin kind, and that wal_next_lsn parses as a decimal integer and does not regress across a write.
  • cargo check -p nodedb, cargo fmt --all -- --check, and a lib clippy run are clean.
  • Mutation arm: with the router arm removed, show_snapshot_returns_the_wal_pin fails; restored, it passes.

What CI does not cover locally

  • 32-bit and ASan fuzz targets, and the full nightly matrix.

Closes #370

Copilot AI balanced review requested due to automatic review settings October 1, 2026 22:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

A reader that pages with a fresh snapshot per page can land between two
producer transactions and return a half-applied batch, with no token to tell a
complete page from an incomplete one.

SHOW SNAPSHOT returns the monotonic WAL sequence at the moment of the call,
with the node id and the build version. Capture the pin once, and a producer
that records the same pin in its commit marker lets the reader decide whether
the batch it paged is complete.

Not tenant-admin gated: it exposes no tenant data, and a reader needs the pin
before it has paged anything.
@EnRaiha
EnRaiha force-pushed the pr/374-370-show-snapshot branch from d1f707e to 62e8f4a Compare October 2, 2026 07:24
@farhan-syah farhan-syah closed this Oct 3, 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

3 participants