Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: fix the race of TestRaftClusterMultipleRestart #8686

Merged
merged 2 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/replication/replication_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ func (m *ModeManager) Run(ctx context.Context) {
select {
case <-timer.C:
case <-ctx.Done():
log.Info("replication mode manager is stopped")
return
}

Expand Down Expand Up @@ -383,6 +384,7 @@ func (m *ModeManager) Run(ctx context.Context) {
}()

wg.Wait()
log.Info("replication mode manager is stopped")
}

func minimalUpVoters(rule *placement.Rule, upStores, downStores []*core.StoreInfo) int {
Expand Down
5 changes: 5 additions & 0 deletions server/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,11 @@ func (c *RaftCluster) Stop() {
log.Info("raft cluster is stopped")
}

// Wait blocks until the cluster is stopped. Only for test purpose.
func (c *RaftCluster) Wait() {
c.wg.Wait()
}

// IsRunning return if the cluster is running.
func (c *RaftCluster) IsRunning() bool {
c.RLock()
Expand Down
2 changes: 2 additions & 0 deletions tests/server/cluster/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,8 @@ func TestRaftClusterMultipleRestart(t *testing.T) {
// let the job run at small interval
re.NoError(failpoint.Enable("github.com/tikv/pd/server/cluster/highFrequencyClusterJobs", `return(true)`))
for i := 0; i < 100; i++ {
// See https://github.com/tikv/pd/issues/8543
rc.Wait()
err = rc.Start(leaderServer.GetServer())
re.NoError(err)
time.Sleep(time.Millisecond)
Expand Down