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

test: Fix race condition in provisionerd on cleanup #322

Merged
merged 2 commits into from
Feb 18, 2022
Merged

Conversation

kylecarbs
Copy link
Member

These goroutines could be ran after the pipe has already been closed.
I'm not certain this resolves this specific leak:

https://github.com/coder/coder/runs/5249481202?check_suite_focus=true#step:7:186

...but I find it likely.

These goroutines could be ran after the pipe has already been closed.
I'm not certain this resolves this specific leak:

https://github.com/coder/coder/runs/5249481202?check_suite_focus=true#step:7:186

...but I find it likely.
@kylecarbs kylecarbs self-assigned this Feb 18, 2022
@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #322 (3661d02) into main (c59c0c9) will increase coverage by 3.84%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #322      +/-   ##
==========================================
+ Coverage   63.61%   67.46%   +3.84%     
==========================================
  Files          69      140      +71     
  Lines         786     7407    +6621     
  Branches       77       77              
==========================================
+ Hits          500     4997    +4497     
- Misses        271     1900    +1629     
- Partials       15      510     +495     
Flag Coverage Δ
unittest-go-macos-latest 66.20% <ø> (?)
unittest-go-ubuntu-latest 67.31% <ø> (?)
unittest-go-windows-latest 65.71% <ø> (?)
unittest-js 63.61% <ø> (ø)
Impacted Files Coverage Δ
coderd/provisionerdaemons.go 57.84% <0.00%> (ø)
database/pubsub_memory.go 87.17% <0.00%> (ø)
httpmw/projectparam.go 76.47% <0.00%> (ø)
coderd/parameter/compute.go 71.85% <0.00%> (ø)
httpmw/organizationparam.go 69.81% <0.00%> (ø)
provisioner/terraform/parse.go 77.77% <0.00%> (ø)
peerbroker/listen.go 84.80% <0.00%> (ø)
cli/projectcreate.go 52.40% <0.00%> (ø)
coderd/coderd.go 95.28% <0.00%> (ø)
provisionersdk/transport.go 55.31% <0.00%> (ø)
... and 61 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c59c0c9...3661d02. Read the comment docs.

Comment on lines +409 to +410
ctx, cancelFunc := context.WithCancel(context.Background())
t.Cleanup(cancelFunc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting... it's not clear to me how this will fix it, but I hope it does 🤞

It seems safe in any case, and it seems reasonable for this to be outside the func that starts the server.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not entirely sure either, but t.Cleanup certainly shouldn't be called async from my POV anyways.

@bryphe-coder
Copy link
Contributor

Thanks for investigating this race, @kylecarbs !

@kylecarbs kylecarbs merged commit 6bdef06 into main Feb 18, 2022
@kylecarbs kylecarbs deleted the cancelrace branch February 18, 2022 16:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants