Skip to content

coprocessor: fix the indexlookup push down local lookup range may exceeds the region end#19216

Merged
ti-chi-bot[bot] merged 1 commit intotikv:masterfrom
lcwangchao:fix_65089
Dec 17, 2025
Merged

coprocessor: fix the indexlookup push down local lookup range may exceeds the region end#19216
ti-chi-bot[bot] merged 1 commit intotikv:masterfrom
lcwangchao:fix_65089

Conversation

@lcwangchao
Copy link
Contributor

@lcwangchao lcwangchao commented Dec 17, 2025

What is changed and how it works?

Issue Number: Close #19215

What's Changed:

The int handle will use the `convert_to_prefix_next` as the end of the point-get range. However, the prefix next may exceeds the region end. In the previous implementation, at this time we use the region end as the table scan range end. However, the region range end is in MVCC format, we must decode it to raw format first.

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 17, 2025 06:11
@ti-chi-bot ti-chi-bot bot added do-not-merge/needs-triage-completed dco-signoff: yes Indicates the PR's author has signed the dco. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. contribution This PR is from a community contributor. needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Dec 17, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 17, 2025

Hi @lcwangchao. Thanks for your PR.

I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. release-note-none Denotes a PR that doesn't merit a release note. labels Dec 17, 2025
@ti-chi-bot ti-chi-bot bot removed the do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. label Dec 17, 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 fixes a bug in the index lookup executor where local lookup ranges may exceed the region end boundary. The issue occurs because integer handles use convert_to_prefix_next to calculate the point-get range end, which can exceed the region end. The fix ensures that when the region end is used to cap the range, it is properly decoded from MVCC format to raw format before being assigned to the key range.

Key changes:

  • Decode region end keys from MVCC format to raw format before using them in TableTask key ranges
  • Add error handling for decoding failures with fallback to TiDB-side lookup
  • Update documentation to clarify that TableTask key ranges contain raw keys without MVCC encoding
  • Update tests to properly decode region end keys when constructing expected ranges

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

…eeds the region end

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
@you06
Copy link
Contributor

you06 commented Dec 17, 2025

/ok-to-test

@ti-chi-bot ti-chi-bot bot added ok-to-test Indicates a PR is ready to be tested. and removed needs-ok-to-test Indicates a PR created by contributors and need ORG member send '/ok-to-test' to start testing. labels Dec 17, 2025
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 17, 2025
@lcwangchao
Copy link
Contributor Author

/affect 8.5

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 17, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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:
  • OWNERS [cfzjywxk,crazycs520]

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 17, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 17, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-12-17 06:31:29.498912864 +0000 UTC m=+1627434.312690436: ☑️ agreed by crazycs520.
  • 2025-12-17 07:06:15.695717818 +0000 UTC m=+1629520.509495390: ☑️ agreed by cfzjywxk.

@ti-chi-bot ti-chi-bot bot merged commit 6bb8ff3 into tikv:master Dec 17, 2025
9 checks passed
@ti-chi-bot ti-chi-bot bot added this to the Pool milestone Dec 17, 2025
@lcwangchao lcwangchao deleted the fix_65089 branch December 17, 2025 08:00
@lcwangchao
Copy link
Contributor Author

/cherry-pick release-8.5

@ti-chi-bot
Copy link
Member

@lcwangchao: new pull request created to branch release-8.5: #19217.

Details

In response to this:

/cherry-pick release-8.5

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository.

ti-chi-bot bot pushed a commit that referenced this pull request Dec 17, 2025
…eeds the region end (#19216) (#19218)

close #19215

The int handle will use the `convert_to_prefix_next` as the end of the point-get range. However, the prefix next may exceeds the region end. In the previous implementation, at this time we use the region end as the table scan range end. However, the region range end is in MVCC format, we must decode it to raw format first.

Signed-off-by: Chao Wang <cclcwangchao@hotmail.com>
bufferflies pushed a commit to bufferflies/tikv that referenced this pull request Dec 26, 2025
…eeds the region end (tikv#19216) (tikv#4165)

* coprocessor: fix the indexlookup push down local lookup range may exceeds the region end (tikv#19216)

close tikv#19215

The int handle will use the `convert_to_prefix_next` as the end of the point-get range. However, the prefix next may exceeds the region end. In the previous implementation, at this time we use the region end as the table scan range end. However, the region range end is in MVCC format, we must decode it to raw format first.

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

* format

Signed-off-by: crazycs520 <crazycs520@gmail.com>

---------

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

Labels

approved contribution This PR is from a community contributor. dco-signoff: yes Indicates the PR's author has signed the dco. lgtm ok-to-test Indicates a PR is ready to be tested. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request range exceeds bound in index lookup pushdown

6 participants