Skip to content

feat(transaction): add Transaction::start_ts and scan_unbounded#554

Open
ariesdevil wants to merge 1 commit into
tikv:masterfrom
ariesdevil:dev_ariesdevil
Open

feat(transaction): add Transaction::start_ts and scan_unbounded#554
ariesdevil wants to merge 1 commit into
tikv:masterfrom
ariesdevil:dev_ariesdevil

Conversation

@ariesdevil

@ariesdevil ariesdevil commented Jul 24, 2026

Copy link
Copy Markdown
  • start_ts exposes the transaction's TSO start timestamp, matching client-go's KVTxn.StartTS.

  • scan_unbounded (on Transaction and Snapshot) returns all pairs in a range by paginating internally in batches of 1024, matching client-go's KVSnapshot.
    Iter semantics: a short page means the range is exhausted, a full page advances past the last key.

Summary by CodeRabbit

  • New Features
    • Added unbounded range scanning for transactions and snapshots, automatically retrieving all matching records across multiple batches.
    • Added access to a transaction’s start timestamp.
  • Tests
    • Expanded coverage for the new transaction timestamp accessor and unbounded scan pagination behavior.

@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign marsishandsome for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot Bot added contribution This PR is from a community contributor. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. dco-signoff: no Indicates the PR's author has not signed dco. labels Jul 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

Welcome @ariesdevil!

It looks like this is your first PR to tikv/client-rust 🎉.

I'm the bot to help you request reviewers, add labels and more, See available commands.

We want to make sure your contribution gets all the attention it needs!



Thank you, and welcome to tikv/client-rust. 😃

@ti-chi-bot ti-chi-bot Bot added the first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. label Jul 24, 2026
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7e717407-3b1f-4568-822a-e05f9a42b13a

📥 Commits

Reviewing files that changed from the base of the PR and between dd640ed and 2bfa214.

📒 Files selected for processing (2)
  • src/transaction/snapshot.rs
  • src/transaction/transaction.rs
🚧 Files skipped from review as they are similar to previous changes (2)
  • src/transaction/snapshot.rs
  • src/transaction/transaction.rs

📝 Walkthrough

Walkthrough

Transaction exposes its start timestamp and adds paginated unbounded range scanning. Snapshot delegates the new scan API, while tests verify timestamp retrieval, batch sizing, pagination, call counts, ordering, and values.

Changes

Transaction scanning

Layer / File(s) Summary
Transaction scan implementation
src/transaction/transaction.rs
Adds start_ts() and paginated scan_unbounded() using fixed-size scan batches and successive keys.
Snapshot surface and validation
src/transaction/snapshot.rs, src/transaction/transaction.rs
Adds the Snapshot delegation wrapper and tests for timestamp access and multi-page scan results.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Snapshot
  participant Transaction
  participant PdClient
  Snapshot->>Transaction: scan_unbounded(range)
  Transaction->>PdClient: scan(start, end, batch size)
  PdClient-->>Transaction: page of KvPair results
  Transaction->>PdClient: scan(next key, end, batch size)
  PdClient-->>Transaction: final page of KvPair results
  Transaction-->>Snapshot: all KvPair results
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main changes: adding Transaction::start_ts and scan_unbounded.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ti-chi-bot ti-chi-bot Bot added dco-signoff: yes Indicates the PR's author has signed the dco. and removed dco-signoff: no Indicates the PR's author has not signed dco. labels Jul 24, 2026

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/transaction/transaction.rs`:
- Around line 122-127: Update the documentation for the transaction start
timestamp accessor to describe start_ts solely as the transaction’s read
timestamp. Remove claims that writes become visible at this timestamp or that
its physical component is suitable for commit, lease, or fencing semantics;
clarify that visibility is determined by the commit timestamp.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e1b0c858-08d6-4555-82b4-3d9b87eec3e9

📥 Commits

Reviewing files that changed from the base of the PR and between 2c0f2f3 and dd640ed.

📒 Files selected for processing (2)
  • src/transaction/snapshot.rs
  • src/transaction/transaction.rs

Comment thread src/transaction/transaction.rs Outdated
Signed-off-by: Yijun Zhao <ariesdevil77@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. first-time-contributor Indicates that the PR was contributed by an external member and is a first-time contributor. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant