From 9e7a1b975d4ca63baffb23de80396cb324f64095 Mon Sep 17 00:00:00 2001 From: okJiang <819421878@qq.com> Date: Thu, 22 Aug 2024 15:52:42 +0800 Subject: [PATCH] *: make TestStores stable (#8522) close tikv/pd#7954 add a failpoint to make sure the offline store do not convert to tombstone Signed-off-by: okJiang <819421878@qq.com> --- server/cluster/cluster.go | 7 +++++-- tests/integrations/mcs/scheduling/api_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 7 deletions(-) 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()