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

Fixed goroutine leak in server/etcdserver/raft_test.go #14286

Merged
merged 1 commit into from
Aug 2, 2022

Conversation

VladSaioc
Copy link
Contributor

@VladSaioc VladSaioc commented Jul 31, 2022

package: etcdserver

Potential for goroutine leak in TestStopRaftWhenWaitingForApplyDone. Timeout case will lead raft node goroutine to block at a select statement. Stopping raft node before calling t.Fatalf will unblock the select and terminate the child goroutine.

@VladSaioc VladSaioc force-pushed the bugfix-goroutine-leak branch from 3a81b22 to 90bb7ac Compare July 31, 2022 14:25
@VladSaioc VladSaioc marked this pull request as ready for review July 31, 2022 14:25
@codecov-commenter
Copy link

codecov-commenter commented Jul 31, 2022

Codecov Report

Merging #14286 (6cded3d) into main (046c46e) will decrease coverage by 0.38%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##             main   #14286      +/-   ##
==========================================
- Coverage   75.69%   75.30%   -0.39%     
==========================================
  Files         456      456              
  Lines       37036    37036              
==========================================
- Hits        28035    27891     -144     
- Misses       7273     7389     +116     
- Partials     1728     1756      +28     
Flag Coverage Δ
all 75.30% <ø> (-0.39%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
server/etcdserver/api/rafthttp/peer_status.go 87.87% <0.00%> (-12.13%) ⬇️
server/etcdserver/api/rafthttp/peer.go 87.01% <0.00%> (-8.45%) ⬇️
client/pkg/v3/fileutil/lock_linux.go 72.22% <0.00%> (-8.34%) ⬇️
client/pkg/v3/tlsutil/tlsutil.go 83.33% <0.00%> (-8.34%) ⬇️
client/v3/concurrency/key.go 80.00% <0.00%> (-8.00%) ⬇️
server/storage/mvcc/watchable_store.go 84.78% <0.00%> (-7.98%) ⬇️
client/pkg/v3/fileutil/purge.go 66.03% <0.00%> (-7.55%) ⬇️
client/pkg/v3/testutil/leak.go 62.83% <0.00%> (-7.08%) ⬇️
client/v3/leasing/util.go 91.66% <0.00%> (-6.67%) ⬇️
raft/rafttest/node.go 95.00% <0.00%> (-5.00%) ⬇️
... and 22 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@@ -171,6 +171,7 @@ func TestStopRaftWhenWaitingForApplyDone(t *testing.T) {
select {
case <-srv.r.applyc:
case <-time.After(time.Second):
srv.r.stop()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The srv.r.stop() may be blocked. I would suggest to follow the same way as line 178 ~ 183, which can be wrapped in a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@VladSaioc VladSaioc force-pushed the bugfix-goroutine-leak branch from 90bb7ac to 6cded3d Compare August 2, 2022 21:23
Copy link
Member

@ahrtr ahrtr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Thank you @VladSaioc

@ahrtr ahrtr merged commit ae36a57 into etcd-io:main Aug 2, 2022
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.

3 participants