mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Fix goroutine leaks in TestCommitPagination
raft: fix goroutine leaks in TestCommitPagination The goroutine created with n.run() will leak if we forget to call n.Stop(). We can replay the goroutine leaks by using [goleak](https://github.com/uber-go/goleak): ``` $ cd raft && env go test -short -v -timeout=3m --race -run=TestCommitPagination. ... ... raft2021/12/27 20:47:15 INFO: raft.node: 1 elected leader 1 at term 1 leaks.go:78: found unexpected goroutines: [Goroutine 20 in state select, with go.etcd.io/etcd/raft/v3.(*node).run on top of the stack: goroutine 20 [select]: go.etcd.io/etcd/raft/v3.(*node).run(0xc00036f260) /home/yuanting/work/dev/goprojects/etcd/raft/node.go:344 +0xc1d created by go.etcd.io/etcd/raft/v3.TestCommitPagination /home/yuanting/work/dev/goprojects/etcd/raft/node_test.go:920 +0x554 ] --- FAIL: TestCommitPagination (0.45s) FAIL FAIL go.etcd.io/etcd/raft/v3 0.508s FAIL ```
This commit is contained in:
parent
69279532f4
commit
df8efd3853
@ -945,6 +945,7 @@ func TestCommitPagination(t *testing.T) {
|
||||
}
|
||||
s.Append(rd.Entries)
|
||||
n.Advance()
|
||||
n.Stop()
|
||||
}
|
||||
|
||||
type ignoreSizeHintMemStorage struct {
|
||||
|
Loading…
x
Reference in New Issue
Block a user