Skip to content

Conversation

@tenfyzhong
Copy link
Collaborator

@tenfyzhong tenfyzhong commented Feb 11, 2026

What problem does this PR solve?

Issue Number: close #4192

What is changed and how it works?

This PR adds an explicit scan boundary for lock resolving in logservice/txnutil/lock_resolver.go.

  • Cache region EndKey together with StartKey when locating the region.
  • Set ScanLockRequest.EndKey on every scan request.
  • Keep lock scanning bounded to the target region to avoid returning out-of-region locks in boundary edge cases.

Check List

Tests

  • Unit test

go test ./logservice/txnutil/...

Questions

Will it cause performance regression or break compatibility?

No. This only tightens scan range boundaries for existing region-scoped lock resolving.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

None

Summary by CodeRabbit

  • Bug Fixes
    • Improved lock scanning efficiency by properly constraining scan operations to appropriate region boundaries, preventing unnecessary checks beyond intended ranges.

Signed-off-by: tenfyzhong <tenfy@tenfy.cn>
@ti-chi-bot ti-chi-bot bot added the release-note-none Denotes a PR that doesn't merit a release note. label Feb 11, 2026
@gemini-code-assist
Copy link

Summary of Changes

Hello @tenfyzhong, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refines the lock resolution mechanism by introducing explicit scan boundaries. By caching and utilizing the region's end key, the system can more accurately constrain lock scan requests to their intended regions, thereby preventing the unintended return of out-of-region locks and enhancing the robustness of the transaction utility.

Highlights

  • Explicit Scan Boundary: An explicit scan boundary has been added for lock resolving in logservice/txnutil/lock_resolver.go to ensure scans remain within the target region.
  • Region EndKey Caching: The region's EndKey is now cached alongside its StartKey when locating a region, making it available for scan requests.
  • Bounded Lock Scanning: The ScanLockRequest.EndKey is now explicitly set on every scan request, preventing out-of-region locks from being returned in boundary edge cases.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • logservice/txnutil/lock_resolver.go
    • Declared a new variable endKey to store the region's end key.
    • Populated the endKey variable with the loc.EndKey when locating a region.
    • Set the EndKey field of the ScanLockRequest using the newly cached endKey.
Activity
  • No activity has been recorded for this pull request yet.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@ti-chi-bot ti-chi-bot bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Feb 11, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 11, 2026

📝 Walkthrough

Walkthrough

This change adds explicit region boundary handling to the lock resolver's ScanLock requests. A new endKey variable tracks the region's end boundary, which is set during region flush and applied to each ScanLock request to prevent scanning locks outside the target region.

Changes

Cohort / File(s) Summary
Lock Resolver Boundary Handling
logservice/txnutil/lock_resolver.go
Introduces endKey variable initialized from region's EndKey and applies it as the scan boundary in ScanLock requests, ensuring locks are only scanned within the target region's bounds.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Suggested labels

lgtm, approved, size/XS

Suggested reviewers

  • asddongmen
  • flowbehappy

Poem

🔐 A lock resolver, careful and wise,
Now bounds its scan with region-wise eyes,
No locks shall roam beyond the fence,
Defensive code—pure excellence! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding a region end key boundary to scan lock operations.
Description check ✅ Passed The description follows the template structure, includes linked issue number, explains the changes clearly, specifies test approach, and addresses all required sections.
Linked Issues check ✅ Passed The code changes directly implement the requirement from issue #4192 by caching region EndKey and setting ScanLockRequest.EndKey to keep scans bounded to the target region.
Out of Scope Changes check ✅ Passed All changes in lock_resolver.go are directly related to bounding scan lock requests by region end key, with no out-of-scope modifications detected.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

No actionable comments were generated in the recent review. 🎉


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 and usage tips.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly bounds the lock scanning process in the logservice to the specific region's boundaries by utilizing the EndKey from the region's location cache. The changes in logservice/txnutil/lock_resolver.go are straightforward: a new variable endKey is introduced, populated with the region's end key, and then used to set the EndKey on the ScanLockRequest. This is a valuable correctness fix that prevents the lock resolver from scanning beyond the intended region, especially in boundary cases. The implementation is clean and I have no suggestions for improvement.

@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Feb 11, 2026
@tenfyzhong
Copy link
Collaborator Author

/test light

@tenfyzhong
Copy link
Collaborator Author

/test heavy

@tenfyzhong
Copy link
Collaborator Author

/retest

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 11, 2026

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 3AceShowHand, lidezhu

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 [3AceShowHand,lidezhu]

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 Feb 11, 2026
@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 11, 2026

[LGTM Timeline notifier]

Timeline:

  • 2026-02-11 09:38:47.411257014 +0000 UTC m=+11280.491247709: ☑️ agreed by 3AceShowHand.
  • 2026-02-11 12:06:45.006680716 +0000 UTC m=+20158.086671411: ☑️ agreed by lidezhu.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Feb 11, 2026

@tenfyzhong: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cdc-pulsar-integration-heavy-next-gen afa0b4d link unknown /test pull-cdc-pulsar-integration-heavy-next-gen
pull-cdc-pulsar-integration-heavy afa0b4d link unknown /test pull-cdc-pulsar-integration-heavy

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

@ti-chi-bot ti-chi-bot bot merged commit a583027 into pingcap:master Feb 11, 2026
23 of 27 checks passed
tenfyzhong added a commit that referenced this pull request Feb 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bound ScanLock by region EndKey in lock resolver

3 participants