Skip to content

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

Merged
ti-chi-bot[bot] merged 7 commits into
pingcap:release-nextgen-202603from
ti-chi-bot:cherry-pick-11016-to-release-nextgen-202603
Aug 11, 2026
Merged

Invalidate read-index cache when lock is found (#11016)#11023
ti-chi-bot[bot] merged 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
@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.

@ti-chi-bot ti-chi-bot Bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Aug 10, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gengliqi, JaySon-Huang

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 [JaySon-Huang,gengliqi]

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 Aug 11, 2026
@ti-chi-bot

ti-chi-bot Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

[LGTM Timeline notifier]

Timeline:

  • 2026-08-10 12:17:40.942345487 +0000 UTC m=+3048846.978440543: ☑️ agreed by JaySon-Huang.
  • 2026-08-11 03:58:41.408693094 +0000 UTC m=+3105307.444788150: ☑️ agreed by gengliqi.

@ti-chi-bot
ti-chi-bot Bot merged commit 1e68c6f into pingcap:release-nextgen-202603 Aug 11, 2026
6 checks passed
@ti-chi-bot
ti-chi-bot Bot deleted the cherry-pick-11016-to-release-nextgen-202603 branch August 11, 2026 05:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm 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.

4 participants