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

fix: Leaking yamux session after HTTP handler is closed #329

Merged
merged 4 commits into from
Feb 19, 2022
Merged

Conversation

kylecarbs
Copy link
Member

Closes #317. The httptest server cancels the context after the connection
is closed, but if a connection takes a long time to close, the request
would never end. This applies a context to the entire listener that cancels
on test cleanup.

After discussion with @bryphe-coder, reducing the parallel limit on
Windows is likely to reduce failures as well.

@kylecarbs kylecarbs self-assigned this Feb 18, 2022
@codecov
Copy link

codecov bot commented Feb 18, 2022

Codecov Report

Merging #329 (8372c59) into main (f7b4849) will increase coverage by 3.84%.
The diff coverage is 82.14%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #329      +/-   ##
==========================================
+ Coverage   63.61%   67.45%   +3.84%     
==========================================
  Files          69      140      +71     
  Lines         786     7443    +6657     
  Branches       77       77              
==========================================
+ Hits          500     5021    +4521     
- Misses        271     1910    +1639     
- Partials       15      512     +497     
Flag Coverage Δ
unittest-go-macos-latest 66.29% <82.14%> (?)
unittest-go-ubuntu-latest 67.47% <82.14%> (?)
unittest-go-windows-2022 65.70% <94.44%> (?)
unittest-js 63.61% <ø> (ø)
Impacted Files Coverage Δ
pty/pty_other.go 35.89% <60.00%> (ø)
pty/start_other.go 70.83% <60.00%> (ø)
provisionerd/provisionerd.go 69.33% <66.66%> (ø)
coderd/coderdtest/coderdtest.go 100.00% <100.00%> (ø)
peer/conn.go 76.72% <100.00%> (ø)
codersdk/files.go 76.92% <0.00%> (ø)
site/embed.go 83.14% <0.00%> (ø)
cli/workspaces.go 100.00% <0.00%> (ø)
database/pubsub_memory.go 87.17% <0.00%> (ø)
... and 66 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 f7b4849...8372c59. Read the comment docs.

@kylecarbs kylecarbs force-pushed the closerace branch 2 times, most recently from 263f17a to 6126814 Compare February 18, 2022 23:22
Closes #317. The httptest server cancels the context after the connection
is closed, but if a connection takes a long time to close, the request
would never end. This applies a context to the entire listener that cancels
on test cleanup.

After discussion with @bryphe-coder, reducing the parallel limit on
Windows is likely to reduce failures as well.
@kylecarbs kylecarbs enabled auto-merge (squash) February 19, 2022 01:03
@@ -150,9 +150,13 @@ jobs:
terraform_wrapper: false

- name: Test with Mock Database
shell: bash
env:
GOCOUNT: ${{ runner.os == 'Windows' && 3 || 5 }}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice addition 👍

srv := httptest.NewServer(handler)
srv := httptest.NewUnstartedServer(handler)
srv.Config.BaseContext = func(_ net.Listener) context.Context {
ctx, cancelFunc := context.WithCancel(context.Background())
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice catch... It's surprising that this is necessary, but glad you found it.

Copy link
Member Author

Choose a reason for hiding this comment

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

It genuinely amazed me.

Copy link
Contributor

@bryphe-coder bryphe-coder left a comment

Choose a reason for hiding this comment

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

Thanks for working so hard to track these down @kylecarbs !

@kylecarbs kylecarbs enabled auto-merge (squash) February 19, 2022 01:12
@@ -122,7 +122,7 @@ jobs:
os:
- ubuntu-latest
- macos-latest
- windows-latest
- windows-2022
Copy link
Contributor

Choose a reason for hiding this comment

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

Per our discussion in slack - we may want to consider bumping the cache in one of these ways:

  • Adding a -v0- parameter that we can bump to invalidate the cache
  • Using matrix.os instead of runner.os for the cache here - that will use windows-2022 instead of windows for the cache key

Copy link
Member Author

Choose a reason for hiding this comment

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

Ahh that's a great idea! Changing now.

@kylecarbs kylecarbs merged commit 65de96c into main Feb 19, 2022
@kylecarbs kylecarbs deleted the closerace branch February 19, 2022 04:06
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.

Fix websocket/yamux/drpc goleak failure on Windows
2 participants