Skip to content

feat(pagination): collision-proof cursor pagination for batch-ingested rows - #404

Open
woahwhattheheck wants to merge 6 commits into
Stellar-Analysis:mainfrom
woahwhattheheck:feat/collision-proof-cursor-pagination
Open

woahwhattheheck wants to merge 6 commits into
Stellar-Analysis:mainfrom
woahwhattheheck:feat/collision-proof-cursor-pagination

Conversation

@woahwhattheheck

Copy link
Copy Markdown

Closes #330

Adds backend pagination with a compound (timestamp, id) cursor so corridor/anchor/transaction list endpoints do not skip or duplicate rows when many share an ingestion timestamp after batch ledger writes.

Design

  • Opaque URL-safe base64 cursor over { "ts": <ms>, "id": "<tiebreaker>" }.
  • Seek predicate for descending pages: (ts, id) < (cursor.ts, cursor.id) (ascending inverts).
  • Callers should index (ts, id) for efficient seeking.
  • Encoding format documented in backend/src/pagination/mod.rs.

Tests

  • batch_collision_test.rs — identical-timestamp batch, small page size, every row exactly once.
  • concurrent_write_stability_test.rs — background inserts while paginating; already-issued cursors stay stable.
cd backend && cargo test

Compatibility

  • New crate module under backend/; focused on pagination only.
  • No unrelated rewrites.

…rows

Encode cursors as opaque (timestamp, id) tuples so ledger-derived rows
that share an ingestion timestamp paginate without skips or duplicates.
Includes batch collision and concurrent-write stability tests, plus
cursor encoding docs in the module rustdoc.
@vercel

vercel Bot commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

@woahwhattheheck is attempting to deploy a commit to the christabel888's projects Team on Vercel.

A member of the Team first needs to authorize it.

Use saturating addition before the existing snapshot clamp so a large
usize page limit remains an upper bound after a cursor or at exhaustion.
Preserve cursor ordering and encoding, and extend the existing batch
regressions for both directions and maximum-size limits.
Sort references to the input snapshot rather than deep-cloning the full
snapshot and cloning the page a second time. Preserve stable compound-key
order, cursor boundaries, the saturated page-end fix, and input ordering.

Add one focused clone-count and result regression covering both directions,
same-timestamp boundaries, exhausted and zero-sized pages, and oversized
limits. No dependencies, public API, cursor encoding, or storage changes.

Rust checks have not been executed for this continuation; existing results
remain scoped to their previously tested source.
@woahwhattheheck

Copy link
Copy Markdown
Author

I am claiming consideration for any GrantFox reward applicable to my contribution in this PR for #330, payable to @woahwhattheheck. Please confirm that this PR is associated with the original contributor's campaign record and included in the reward evaluation, and confirm any allocation and payout date once approved. Existing contributors' attribution and any remaining acceptance requirements remain documented in this PR.

This branch has not been deployed

No deployments
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.

Collision-proof cursor pagination for batch-ingested rows

1 participant