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

Leave websocket transport open if receive times out or is cancelled #8251

Merged
merged 10 commits into from
Mar 29, 2024

Conversation

bdraco
Copy link
Member

@bdraco bdraco commented Mar 26, 2024

What do these changes do?

Leave websocket transport open if receive times out or is cancelled.

This change restores the behavior before #7978

See #7978 (comment)

Are there changes in behavior for the user?

The connection is left open if the receive call times out or is cancelled

Is it a substantial burden for the maintainers to support this?

no

Related issue number

#7978 (comment)

Checklist

  • I think the code is well written
  • Unit tests for the changes exist
  • Documentation reflects the changes
  • If you provide code modification, please add yourself to CONTRIBUTORS.txt
    • The format is <Name> <Surname>.
    • Please keep alphabetical order, the file is sorted by names.
  • Add a new news fragment into the CHANGES/ folder
    • name it <issue_or_pr_num>.<type>.rst (e.g. 588.bugfix.rst)

    • if you don't have an issue number, change it to the pull request
      number after creating the PR

      • .bugfix: A bug fix for something the maintainers deemed an
        improper undesired behavior that got corrected to match
        pre-agreed expectations.
      • .feature: A new behavior, public APIs. That sort of stuff.
      • .deprecation: A declaration of future API removals and breaking
        changes in behavior.
      • .breaking: When something public is removed in a breaking way.
        Could be deprecated in an earlier release.
      • .doc: Notable updates to the documentation structure or build
        process.
      • .packaging: Notes for downstreams about unobvious side effects
        and tooling. Changes in the test invocation considerations and
        runtime assumptions.
      • .contrib: Stuff that affects the contributor experience. e.g.
        Running tests, building the docs, setting up the development
        environment.
      • .misc: Changes that are hard to assign to any of the above
        categories.
    • Make sure to use full sentences with correct case and punctuation,
      for example:

      Fixed issue with non-ascii contents in doctest text files
      -- by :user:`contributor-gh-handle`.

      Use the past tense or the present tense a non-imperative mood,
      referring to what's changed compared to the last released version
      of this project.

@psf-chronographer psf-chronographer bot added the bot:chronographer:provided There is a change note present in this PR label Mar 26, 2024
tests/test_web_websocket_functional.py Dismissed Show dismissed Hide dismissed
tests/test_web_websocket_functional.py Dismissed Show dismissed Hide dismissed
tests/test_web_websocket_functional.py Fixed Show fixed Hide fixed
tests/test_web_websocket_functional.py Dismissed Show dismissed Hide dismissed
tests/test_web_websocket_functional.py Dismissed Show dismissed Hide dismissed
tests/test_web_websocket_functional.py Dismissed Show dismissed Hide dismissed
@bdraco bdraco added backport-3.9 backport-3.10 Trigger automatic backporting to the 3.10 release branch by Patchback robot labels Mar 26, 2024
Copy link

codecov bot commented Mar 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 97.56%. Comparing base (6ec4747) to head (249d5cf).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #8251   +/-   ##
=======================================
  Coverage   97.56%   97.56%           
=======================================
  Files         107      107           
  Lines       32936    32999   +63     
  Branches     3851     3853    +2     
=======================================
+ Hits        32133    32196   +63     
  Misses        602      602           
  Partials      201      201           
Flag Coverage Δ
CI-GHA 97.48% <100.00%> (+<0.01%) ⬆️
OS-Linux 97.14% <100.00%> (+<0.01%) ⬆️
OS-Windows 95.82% <100.00%> (+<0.01%) ⬆️
OS-macOS 96.96% <100.00%> (+0.01%) ⬆️
Py-3.10.11 95.56% <100.00%> (+<0.01%) ⬆️
Py-3.10.13 96.70% <100.00%> (+<0.01%) ⬆️
Py-3.10.14 96.92% <100.00%> (+<0.01%) ⬆️
Py-3.11.8 96.93% <100.00%> (+<0.01%) ⬆️
Py-3.12.2 97.06% <100.00%> (+<0.01%) ⬆️
Py-3.8.10 95.54% <100.00%> (+<0.01%) ⬆️
Py-3.8.18 96.89% <100.00%> (+<0.01%) ⬆️
Py-3.9.13 95.53% <100.00%> (+<0.01%) ⬆️
Py-3.9.18 96.67% <100.00%> (+<0.01%) ⬆️
Py-3.9.19 96.89% <100.00%> (+<0.01%) ⬆️
Py-pypy7.3.15 96.46% <100.00%> (+<0.01%) ⬆️
VM-macos 96.96% <100.00%> (+0.01%) ⬆️
VM-ubuntu 97.14% <100.00%> (+<0.01%) ⬆️
VM-windows 95.82% <100.00%> (+<0.01%) ⬆️

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

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bdraco
Copy link
Member Author

bdraco commented Mar 26, 2024

Tested on production. No adverse effects observed. Old behavior restored without the leak

@bdraco bdraco marked this pull request as ready for review March 26, 2024 23:21
@Dreamsorcerer
Copy link
Member

And this still fixes the leak from before? I was thinking that we'd close the connection if the connection timed out (indicating that we may have lost the connection), but would keep the connection if it was cancelled externally.

@Dreamsorcerer
Copy link
Member

Also, setting the close code to abnormal closure still seems like we're attempting to close the connection to me. That still doesn't seem like the right behaviour when the task has been cancelled externally. I think no action should be taken in that situation (though, if someone is always putting a timeout on, then maybe there are issues with it never detecting the connection is timed out?).

@bdraco
Copy link
Member Author

bdraco commented Mar 28, 2024

And this still fixes the leak from before? I was thinking that we'd close the connection if the connection timed out (indicating that we may have lost the connection), but would keep the connection if it was cancelled externally.

Yes, the original problem was in close, and the change to receive wasn't needed. I changed it to be consistent but that seems incorrect in hindsight.

@bdraco
Copy link
Member Author

bdraco commented Mar 28, 2024

Also, setting the close code to abnormal closure still seems like we're attempting to close the connection to me. That still doesn't seem like the right behaviour when the task has been cancelled externally. I think no action should be taken in that situation (though, if someone is always putting a timeout on, then maybe there are issues with it never detecting the connection is timed out?).

I did a strait revert to the previous version, but I agree that seems wrong as well. I think it should simply raise here instead

@bdraco bdraco marked this pull request as draft March 28, 2024 07:21
@bdraco
Copy link
Member Author

bdraco commented Mar 28, 2024

I made that change in the code, but I'm too tired to retest it so marked it back as draft until I've had more sleep and can test it properly

@bdraco
Copy link
Member Author

bdraco commented Mar 28, 2024

Functional testing looks good on production

@bdraco bdraco marked this pull request as ready for review March 28, 2024 23:16
@bdraco
Copy link
Member Author

bdraco commented Mar 29, 2024

Everything ran ok overnight. Nothing in the logs. All looks good

@bdraco bdraco merged commit c21b76d into master Mar 29, 2024
34 checks passed
@bdraco bdraco deleted the no_close_receive_cancelled branch March 29, 2024 22:58
Copy link
Contributor

patchback bot commented Mar 29, 2024

Backport to 3.9: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.9/c21b76d0eb66827982a1875798b50a6028f51df0/pr-8251

Backported as #8263

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

Copy link
Contributor

patchback bot commented Mar 29, 2024

Backport to 3.10: 💚 backport PR created

✅ Backport PR branch: patchback/backports/3.10/c21b76d0eb66827982a1875798b50a6028f51df0/pr-8251

Backported as #8264

🤖 @patchback
I'm built with octomachinery and
my source is open — https://github.com/sanitizers/patchback-github-app.

patchback bot pushed a commit that referenced this pull request Mar 29, 2024
bdraco added a commit that referenced this pull request Mar 30, 2024
…receive times out or is cancelled (#8264)

Co-authored-by: J. Nick Koston <nick@koston.org>
bdraco added a commit that referenced this pull request Mar 30, 2024
…eceive times out or is cancelled (#8263)

Co-authored-by: J. Nick Koston <nick@koston.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-3.10 Trigger automatic backporting to the 3.10 release branch by Patchback robot bot:chronographer:provided There is a change note present in this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants