Skip to content

Invalidate read-index cache when lock is found (#11016) - #11023

Open
ti-chi-bot wants to merge 7 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-11016-to-release-nextgen-202603
Open

Invalidate read-index cache when lock is found (#11016)#11023
ti-chi-bot wants to merge 7 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-11016-to-release-nextgen-202603

Conversation

@ti-chi-bot

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #11016

What problem does this PR solve?

Issue Number: close #10985

Problem Summary:

When TiFlash local learner read meets a lock, the read-index result for that region may still be cached. Later retries can reuse the old read-index result even though the lock needs a newer apply progress to be resolved, which can cause unnecessary remote reads or repeated lock handling.

What is changed and how it works?

Invalidate read index cache when lock is found
Print first lock info in lock exception

This PR invalidates the read-index cache when a local lock is found, so later retries need to obtain a fresh read-index result for that region.

It also prints the first lock's detailed info in LockException, making it easier to identify the blocking lock from TiFlash logs without dumping every lock.

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

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Fix the issue that TiFlash may reuse stale read-index cache after meeting a local lock.

Summary by CodeRabbit

  • Bug Fixes

    • Improved read consistency by clearing cached read-index results when lock resolution detects a conflicting lock.
    • Reduced the risk of stale commit-index data being returned for affected regions.
    • Enhanced lock-related error messages with first-lock details and additional debugging information.
    • Ensured related cached query results are refreshed after invalidation.
  • Tests

    • Added coverage confirming invalidated read-index data refreshes and reflects the latest commit index.

Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
Signed-off-by: xufei <xufeixw@mail.ustc.edu.cn>
@ti-chi-bot ti-chi-bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603 labels Aug 7, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

[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 lloyd-pottiger 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

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (3)
  • release-8.5
  • release-7.5
  • release-8.1

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 601ddc9c-2f42-4562-ac5e-2e7191eb4469

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-202603

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants