diff --git a/server/cluster/cluster.go b/server/cluster/cluster.go index 9e85a0f1d84..fdeffd15e9c 100644 --- a/server/cluster/cluster.go +++ b/server/cluster/cluster.go @@ -1669,9 +1669,12 @@ func (c *RaftCluster) checkStores() { if c.IsPrepared() { c.updateProgress(id, store.GetAddress(), removingAction, float64(regionSize), float64(regionSize), false /* dec */) } - regionCount := c.GetStoreRegionCount(id) // If the store is empty, it can be buried. - if regionCount == 0 { + needBury := c.GetStoreRegionCount(id) == 0 + failpoint.Inject("doNotBuryStore", func(_ failpoint.Value) { + needBury = false + }) + if needBury { if err := c.BuryStore(id, false); err != nil { log.Error("bury store failed", zap.Stringer("store", offlineStore), diff --git a/tests/integrations/mcs/scheduling/api_test.go b/tests/integrations/mcs/scheduling/api_test.go index 68f276f9e22..d2027a616cb 100644 --- a/tests/integrations/mcs/scheduling/api_test.go +++ b/tests/integrations/mcs/scheduling/api_test.go @@ -629,13 +629,13 @@ func (suite *apiTestSuite) checkStores(cluster *tests.TestCluster) { Version: "2.0.0", }, } - // prevent the offline store from changing to tombstone - tests.MustPutRegion(re, cluster, 3, 6, []byte("a"), []byte("b")) + + re.NoError(failpoint.Enable("github.com/tikv/pd/server/cluster/doNotBuryStore", `return(true)`)) + defer func() { + re.NoError(failpoint.Disable("github.com/tikv/pd/server/cluster/doNotBuryStore")) + }() for _, store := range stores { tests.MustPutStore(re, cluster, store) - if store.GetId() == 6 { - cluster.GetLeaderServer().GetRaftCluster().GetBasicCluster().UpdateStoreStatus(6) - } } // Test /stores apiServerAddr := cluster.GetLeaderServer().GetAddr()