Skip to content

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

Merged
ti-chi-bot[bot] merged 4 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-10607-to-release-8.5
Dec 12, 2025
Merged

KVStore: ignore non-exist IStorage instance in releasePreHandledSnapshot (#10607)#10613
ti-chi-bot[bot] merged 4 commits intopingcap:release-8.5from
ti-chi-bot:cherry-pick-10607-to-release-8.5

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 12, 2025 07:44
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-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Dec 12, 2025
Signed-off-by: JaySon-Huang <tshent@qq.com>
@ti-chi-bot ti-chi-bot bot added approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 12, 2025
@JaySon-Huang
Copy link
Contributor

/test pull-unit-test

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Dec 12, 2025
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 12, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-12-12 08:28:39.524154634 +0000 UTC m=+1202464.337932216: ☑️ agreed by JaySon-Huang.
  • 2025-12-12 12:05:43.752841959 +0000 UTC m=+1215488.566619521: ☑️ agreed by CalvinNeo.

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 12, 2025

[APPROVALNOTIFIER] This PR is APPROVED

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

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 [CalvinNeo,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 added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Dec 12, 2025
@ti-chi-bot ti-chi-bot bot merged commit 7451e2c into pingcap:release-8.5 Dec 12, 2025
4 checks passed
@ti-chi-bot ti-chi-bot bot deleted the cherry-pick-10607-to-release-8.5 branch December 12, 2025 16:26
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented Dec 12, 2025

@ti-chi-bot: The following test 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-integration-test 98dd6f7 link unknown /test pull-integration-test

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.

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

Labels

approved cherry-pick-approved Cherry pick PR approved by release team. 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-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants