Skip to content

Fix goroutine leaks in TestNodeProposeAddDuplicateNode#13562

Merged
ptabor merged 1 commit intoetcd-io:mainfrom
timmyyuan:main
Jan 14, 2022
Merged

Fix goroutine leaks in TestNodeProposeAddDuplicateNode#13562
ptabor merged 1 commit intoetcd-io:mainfrom
timmyyuan:main

Conversation

@timmyyuan
Copy link
Copy Markdown
Contributor

@timmyyuan timmyyuan commented Dec 27, 2021

raft: fix goroutine leaks in TestNodeProposeAddDuplicateNode

The goroutine created with n.run() will leak if we forget to call n.Stop().

We can replay the goroutine leaks by using goleak:

$ cd raft &&  env go test -short -v -timeout=3m --race -run=TestNodeProposeAddLearnerNode .
... ...
--- FAIL: TestNodeProposeAddLearnerNode (1.15s)
    node_test.go:850: raft: [{1 1 EntryNormal []}]
    node_test.go:850: raft: [{1 2 EntryConfChange [8 0 16 3 24 2]}]
    node_test.go:867: apply raft conf {ConfChangeAddLearnerNode 2 [] 0} changed to: voters:1 learners:2
    leaks.go:82: found unexpected goroutines:
        [Goroutine 22 in state select, with go.etcd.io/etcd/raft/v3.(*node).run on top of the stack:
        goroutine 22 [select]:
        go.etcd.io/etcd/raft/v3.(*node).run(0xc00041b620)
                /home/yuanting/dev/goprojects/etcd/raft/node.go:345 +0xc1d
        created by go.etcd.io/etcd/raft/v3.TestNodeProposeAddLearnerNode
                /home/yuanting/dev/goprojects/etcd/raft/node_test.go:835 +0x4f4
        ]
FAIL
FAIL    go.etcd.io/etcd/raft/v3 1.228s

raft: fix goroutine leaks in TestNodeProposeAddDuplicateNode

The goroutine created with `n.run()` will leak if we forget to call `n.Stop()`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants