Skip to content

*: support returning commit ts for Get / BatchGet / Coprocessor#19230

Merged
ti-chi-bot[bot] merged 3 commits intotikv:masterfrom
lcwangchao:cp_commit_ts
Dec 26, 2025
Merged

*: support returning commit ts for Get / BatchGet / Coprocessor#19230
ti-chi-bot[bot] merged 3 commits intotikv:masterfrom
lcwangchao:cp_commit_ts

Conversation

@lcwangchao
Copy link
Contributor

This is a cherry-pick to support returning the commit ts for Get / BatchGet / Coprocessor

cherry pick the following PRs:

What is changed and how it works?

Issue Number: Close #19102

ref pingcap/tidb#64949

What's Changed:

- The Get / BatchGet will return the commit_ts for each value if `need_commit_ts` is specified.
- coprocessor: support return _tidb_commit_ts column for TableScan coprocessor request

Related changes

  • PR to update pingcap/docs/pingcap/docs-cn:
  • Need to cherry-pick to the release branch

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No code

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Release note

None

Copilot AI review requested due to automatic review settings December 25, 2025 06:02
@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates the PR's author has signed the dco. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Dec 25, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds support for returning commit timestamps with Get/BatchGet/Coprocessor operations, enabling TiDB to retrieve both values and their commit timestamps in a single request. This is a cherry-pick of PRs #19103 and #19166 to resolve issue #19102.

Key changes:

  • Introduces ValueEntry and KvPairEntry types to carry both values and optional commit timestamps
  • Adds load_commit_ts parameters throughout the storage stack to control commit timestamp loading
  • Updates Get/BatchGet RPC handlers to return commit timestamps when need_commit_ts is set
  • Adds support for _tidb_commit_ts virtual column in TableScan coprocessor requests

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
components/txn_types/src/types.rs Defines new ValueEntry and KvPairEntry types to encapsulate values with optional commit timestamps
src/storage/txn/store.rs Extends Store trait with get_entry and incremental_get_entry methods, updates batch_get and scanner signatures to support commit timestamp loading
src/storage/mvcc/reader/point_getter.rs Adds get_entry method and updates lock handling to skip access_locks when commit_ts is required
src/storage/mvcc/reader/scanner/forward.rs Updates LatestKvPolicy to return ValueEntry and load commit timestamps from write CF keys
src/storage/mvcc/reader/scanner/backward.rs Updates BackwardKvScanner to track and return commit timestamps with values
src/storage/mod.rs Adds get_entry method that wraps existing get to support commit timestamp loading
src/server/service/kv.rs Updates Get and BatchGet RPC handlers to check need_commit_ts flag and populate response commit timestamps
src/storage/errors.rs Adds map_kv_pair_entries function and updates mapping logic to handle commit timestamps in responses
components/tidb_query_executors/src/table_scan_executor.rs Implements support for _tidb_commit_ts virtual column in table scans
components/tidb_query_datatype/src/codec/table.rs Defines EXTRA_COMMIT_TS_COL_ID constant for the commit timestamp virtual column
components/tidb_query_common/src/storage/mod.rs Adds OwnedKvPairEntry struct and updates Storage trait with commit timestamp support
components/api_version/src/keyspace.rs Renames KvPair trait to KvPairEntry and adds commit_ts support
tests/integrations/server/kv_service.rs Adds comprehensive tests for Get and BatchGet with commit timestamp support

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lcwangchao lcwangchao force-pushed the cp_commit_ts branch 3 times, most recently from 60c818c to 63d59de Compare December 25, 2025 09:32
@lcwangchao
Copy link
Contributor Author

/hold wait for cargo-deny fix

@ti-chi-bot ti-chi-bot bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 25, 2025
lcwangchao and others added 3 commits December 26, 2025 07:43
…kv#19103)

close tikv#19102

The Get / BatchGet will return the commit_ts for each value if `need_commit_ts` is specified.

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
…ocessor request (tikv#19166)

close pingcap/tidb#64949

coprocessor: support return _tidb_commit_ts column for TableScan coprocessor request

Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
@lcwangchao
Copy link
Contributor Author

/unhold

@ti-chi-bot ti-chi-bot bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 25, 2025
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 26, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 26, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: cfzjywxk, ekexium

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

The pull request process is described 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 lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 26, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 26, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-12-26 06:01:02.37297371 +0000 UTC m=+2403207.186751312: ☑️ agreed by cfzjywxk.
  • 2025-12-26 07:04:04.621479698 +0000 UTC m=+2406989.435257269: ☑️ agreed by ekexium.

@ti-chi-bot ti-chi-bot bot merged commit 147cacc into tikv:master Dec 26, 2025
9 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Dec 26, 2025
@lcwangchao lcwangchao deleted the cp_commit_ts branch December 26, 2025 07:15
lcwangchao added a commit to lcwangchao/tikv that referenced this pull request Jan 20, 2026
…#19230)

close tikv#19102, ref pingcap/tidb#64949

- The Get / BatchGet will return the commit_ts for each value if `need_commit_ts` is specified.
- coprocessor: support return _tidb_commit_ts column for TableScan coprocessor request

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>

Co-authored-by: tiancaiamao <tiancaiamao@gmail.com>
ti-chi-bot bot pushed a commit that referenced this pull request Jan 23, 2026
…) (#19295)

close #19312

support returning commit ts for Get / BatchGet / Coprocessor

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>

Co-authored-by: tiancaiamao <tiancaiamao@gmail.com>
lcwangchao added a commit to lcwangchao/tikv that referenced this pull request Jan 23, 2026
…#19230) (tikv#19295)

close tikv#19312

support returning commit ts for Get / BatchGet / Coprocessor

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>

Co-authored-by: tiancaiamao <tiancaiamao@gmail.com>
lcwangchao added a commit to lcwangchao/tikv that referenced this pull request Jan 23, 2026
…#19230) (tikv#19295)

close tikv#19312

support returning commit ts for Get / BatchGet / Coprocessor

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>

Co-authored-by: tiancaiamao <tiancaiamao@gmail.com>
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
lcwangchao added a commit to lcwangchao/tikv that referenced this pull request Jan 23, 2026
…#19230) (tikv#19295)

close tikv#19312

support returning commit ts for Get / BatchGet / Coprocessor

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
Signed-off-by: tiancaiamao <tiancaiamao@gmail.com>

Co-authored-by: tiancaiamao <tiancaiamao@gmail.com>
Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved dco-signoff: yes Indicates the PR's author has signed the dco. lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support need_commit_ts for Get / BatchGet requests

5 participants