Skip to content

KVStore: ignore non-exist IStorage instance in releasePreHandledSnapshot (#10607)#10616

Merged
ti-chi-bot[bot] merged 3 commits intopingcap:release-nextgen-20251011from
ti-chi-bot:cherry-pick-10607-to-release-nextgen-20251011
Dec 15, 2025
Merged

KVStore: ignore non-exist IStorage instance in releasePreHandledSnapshot (#10607)#10616
ti-chi-bot[bot] merged 3 commits intopingcap:release-nextgen-20251011from
ti-chi-bot:cherry-pick-10607-to-release-nextgen-20251011

Conversation

@ti-chi-bot
Copy link
Member

This is an automated cherry-pick of #10607

What problem does this PR solve?

Issue Number: close #10606

Problem Summary:

  1. During the BR restore process, TiDB first creates tables, performs region pre-splitting, and scatters the resulting regions across nodes. The regions created during this phase are empty.
  2. TiFlash intentionally avoids creating IStorage objects when handling commands such as splits or snapshot applications for empty regions. This design choice helps reduce memory consumption and file fragmentation caused by empty tables in TiFlash.
  3. However, in some cases, after a region is pre-split but before it finishes the PreHandleSnapshot stage, the region gets scheduled away (i.e., moved to another node). This triggers tiflash-proxy to call TiFlash’s releasePreHandledSnapshot.
  4. Inside releasePreHandledSnapshot, the code retrieves an IStorage pointer from TMTStorages but fails to check whether it is a nullptr before directly invoking cleanPreIngestFiles. This missing null check leads to a null pointer dereference (NPE) and causes TiFlash to crash.

What is changed and how it works?

KVStore: ignore non-exist IStorage instance in releasePreHandledSnapshot
* `KVStore::releasePreHandledSnapshot` skip for external files is empty or IStorage instance is not exist

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 a issue that TiFlash may panic during br restore

CalvinNeo and others added 3 commits December 15, 2025 01:51
Signed-off-by: Calvin Neo <calvinneo1995@gmail.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
Signed-off-by: JaySon-Huang <tshent@qq.com>
@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/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-20251011 labels Dec 15, 2025
@ti-chi-bot ti-chi-bot bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Dec 15, 2025
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 15, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 15, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-12-15 01:53:49.474820132 +0000 UTC m=+1437974.288597704: ☑️ agreed by JaySon-Huang.
  • 2025-12-15 02:40:39.3009489 +0000 UTC m=+1440784.114726472: ☑️ agreed by JinheLin.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 15, 2025

@yinshuangfei: adding LGTM is restricted to approvers and reviewers in OWNERS files.

Details

In response to this:

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
Copy link
Contributor

ti-chi-bot bot commented Dec 15, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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,JinheLin]

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 merged commit 98f931b into pingcap:release-nextgen-20251011 Dec 15, 2025
4 checks passed
@ti-chi-bot ti-chi-bot bot deleted the cherry-pick-10607-to-release-nextgen-20251011 branch December 15, 2025 04:27
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/L Denotes a PR that changes 100-499 lines, ignoring generated files. type/cherry-pick-for-release-nextgen-20251011

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants