Skip to content

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

Merged
ti-chi-bot[bot] merged 3 commits intotikv:release-8.5from
lcwangchao:cp_commit_ts
Jan 23, 2026
Merged

*: support returning commit ts for Get / BatchGet / Coprocessor (#19230)#19295
ti-chi-bot[bot] merged 3 commits intotikv:release-8.5from
lcwangchao:cp_commit_ts

Conversation

@lcwangchao
Copy link
Contributor

@lcwangchao lcwangchao commented Jan 20, 2026

This is a cherry-pick of #19230

  • 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

This is also a cherry-pick of #19300

  • coprocessor: fix panic when _tidb_commit_ts column is placed before PK handle columns

This is also a cherry-pick of #19301

  • *: support need_commit_ts for TiKV command batch_get_command

What is changed and how it works?

Issue Number: Close #19312

What's Changed:

support returning commit ts for Get / BatchGet / Coprocessor

Review guidelines

This PR supports returning the commit timestamp for the following cases:

  • When GetRequest / BatchGetRequest has need_commit_ts == true. It will return a non-zero commit_ts in GetResponse / BatchGetResponse.
  • For coprocessor request, when TableScan.columns has a column with id EXTRA_COMMIT_TS_COL_ID which is -5, it fills the commit ts of the row.

Please review this PR and pay close attention to the following points:

  • When need_commit_ts is false or EXTRA_COMMIT_TS_COL_ID is not used, the behavior should be exactly the same as the previous implementation. And the commit_ts field should be zero in GetResponse / BatchGetResponse
  • When need_commit_ts is true or EXTRA_COMMIT_TS_COL_ID one of the columns in the coprocessor request, the right commit ts should be returned. Please take care of some corner cases, for example, when resolved_locks or committed_locks is set in the rpc requests.

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

…#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 ti-chi-bot bot added do-not-merge/cherry-pick-not-approved 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 Jan 20, 2026
@lcwangchao lcwangchao requested a review from Copilot January 20, 2026 00:50
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 in Get/BatchGet operations and introduces the _tidb_commit_ts column for TableScan coprocessor requests. The implementation introduces new type ValueEntry that wraps a value with an optional commit timestamp, and extends the storage layer, MVCC readers, and coprocessor executors to propagate this information.

Changes:

  • Added ValueEntry and KvPairEntry types to wrap values with optional commit timestamps
  • Extended Get/BatchGet APIs to accept need_commit_ts/load_commit_ts parameters
  • Added support for EXTRA_COMMIT_TS_COL_ID column in TableScan executor

Reviewed changes

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

Show a summary per file
File Description
components/txn_types/src/types.rs Added ValueEntry and KvPairEntry types with commit_ts field
src/storage/txn/store.rs Updated Store trait with get_entry, incremental_get_entry, batch_get methods
src/storage/mvcc/reader/point_getter.rs Added get_entry method supporting load_commit_ts flag
src/storage/mvcc/reader/scanner/*.rs Updated scanners to return ValueEntry with commit_ts
src/server/service/kv.rs Modified Get/BatchGet handlers to use need_commit_ts parameter
src/storage/errors.rs Added mapping functions for KvPairEntry to protobuf
components/tidb_query_executors/src/table_scan_executor.rs Added EXTRA_COMMIT_TS_COL_ID column support
components/tidb_query_datatype/src/codec/table.rs Defined EXTRA_COMMIT_TS_COL_ID constant
components/api_version/src/keyspace.rs Updated KvPairEntry trait with commit_ts method
tests/integrations/server/kv_service.rs Added integration tests for Get/BatchGet with need_commit_ts

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

@lcwangchao
Copy link
Contributor Author

/retest

1 similar comment
@lcwangchao
Copy link
Contributor Author

/retest

@lcwangchao
Copy link
Contributor Author

/retest

…K handle columns (tikv#19300)

close tikv#19299

fix panic when _tidb_commit_ts column is placed before PK handle columns

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
…19301)

close tikv#19102

support `need_commit_ts` for TiKV command batch_get_command

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
@ti-chi-bot ti-chi-bot bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jan 23, 2026
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jan 23, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 23, 2026

[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 Jan 23, 2026
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Jan 23, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-01-23 03:43:36.359248847 +0000 UTC m=+724643.973205703: ☑️ agreed by cfzjywxk.
  • 2026-01-23 04:48:25.882666934 +0000 UTC m=+728533.496623790: ☑️ agreed by ekexium.

@ti-chi-bot ti-chi-bot bot merged commit d3464a6 into tikv:release-8.5 Jan 23, 2026
5 checks passed
@lcwangchao lcwangchao deleted the cp_commit_ts branch January 23, 2026 06:00
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 cherry-pick-approved Cherry pick PR approved by release team. 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.

4 participants