Skip to content

Commit

Permalink
Merge pull request etcd-io#14286 from VladSaioc/bugfix-goroutine-leak
Browse files Browse the repository at this point in the history
Fixed goroutine leak in server/etcdserver/raft_test.go
  • Loading branch information
ahrtr authored Aug 2, 2022
2 parents 4f0e92d + 6cded3d commit ae36a57
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions server/etcdserver/raft_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,18 +168,24 @@ func TestStopRaftWhenWaitingForApplyDone(t *testing.T) {
srv := &EtcdServer{lgMu: new(sync.RWMutex), lg: zaptest.NewLogger(t), r: *r}
srv.r.start(nil)
n.readyc <- raft.Ready{}

stop := func() {
srv.r.stopped <- struct{}{}
select {
case <-srv.r.done:
case <-time.After(time.Second):
t.Fatalf("failed to stop raft loop")
}
}

select {
case <-srv.r.applyc:
case <-time.After(time.Second):
stop()
t.Fatalf("failed to receive toApply struct")
}

srv.r.stopped <- struct{}{}
select {
case <-srv.r.done:
case <-time.After(time.Second):
t.Fatalf("failed to stop raft loop")
}
stop()
}

// TestConfigChangeBlocksApply ensures toApply blocks if committed entries contain config-change.
Expand Down

0 comments on commit ae36a57

Please sign in to comment.