From e878b626f436cf83d9549a5e56bf8db8cef4218a Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Tue, 10 Sep 2024 15:38:30 +0800 Subject: [PATCH] schedule: fix panic when switching placement rules (#7415) (#7422) close tikv/pd#7414 Signed-off-by: ti-chi-bot Signed-off-by: Ryan Leung Co-authored-by: Ryan Leung Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> --- server/schedule/checker/rule_checker.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/schedule/checker/rule_checker.go b/server/schedule/checker/rule_checker.go index ea665c1faa9..ac24aaea50b 100644 --- a/server/schedule/checker/rule_checker.go +++ b/server/schedule/checker/rule_checker.go @@ -102,6 +102,11 @@ func (c *RuleChecker) CheckWithFit(region *core.RegionInfo, fit *placement.Regio panic("cached should be used") }) + // the placement rule is disabled + if fit == nil { + return + } + // If the fit is calculated by FitRegion, which means we get a new fit result, thus we should // invalid the cache if it exists c.ruleManager.InvalidCache(region.GetID())