-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Abort ssl connections on close when ssl_shutdown_timeout is 0 #11148
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
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files@@ Coverage Diff @@
## master #11148 +/- ##
==========================================
- Coverage 98.86% 98.85% -0.01%
==========================================
Files 131 131
Lines 42737 42966 +229
Branches 2308 2314 +6
==========================================
+ Hits 42250 42476 +226
- Misses 337 340 +3
Partials 150 150
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
CodSpeed Performance ReportMerging #11148 will not alter performanceComparing Summary
|
I'm still unclear on your changes from #11114 though. The changelog says it's expected behaviour on TLS 1.3. If that's true, we shouldn't be waiting at all, if we expect it to never work. I thought it was only misbehaving servers which don't close the connection properly. |
TLS 1.2 is required to acknowledge immediately. With TLS 1.3 it isn't required but should acknowledge quickly, but it is allowed to flush the buffer first. In practice though misbehaving servers don't flush the buffer and never acknowledge, leaving the user in a state they can do nothing about. I'm almost tempted to change the default to 0 and simply abort the connections since there isn't much value in waiting at all if we are closing the connector. I just worry that we don't flush the buffer in that case, but since the connector is closing, does it matter ? |
The more I think about it, the more I'm leaning to making 0 the default as I can't see any reason we would need to worry about flushing the buffer if we are done with the session/connector |
I'm not too familiar with what the risks are. Feels like some misbehaving servers should be fixed... |
The key risk is we we might not flush the read/write buffer, but if are are done with the session/connector anyways it should be fine to abort. I'm worried about the case where someone expects they have an event loop iteration remaining to read the buffered client data in another task before the connector closes. |
It comes down to, is it reasonable to expect that someone would want to read the buffer after calling .close() on the connector.. I think the answer is no |
I guess my question is who's going to change it from the default? What problem would it fix, and how would a user know they want to change that default? |
I can't actually envision a use case where they would want anything other than the new default in this PR (0). Waiting 0.1s to close the connector is very undesirable when you are frequently creating and destroying them which seems to be a much more common use case than we have expected. |
So, it kind of feels to me like the parameter should be removed again.. |
Yeah I think so. I'll deprecate it for removal in 4.0 |
Backport to 3.12: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 86a9a38 on top of patchback/backports/3.12/86a9a3827c876acfd32886bd51b49df7f5f1925e/pr-11148 Backporting merged PR #11148 into master
🤖 @patchback |
Backport to 3.13: 💔 cherry-picking failed — conflicts found❌ Failed to cleanly apply 86a9a38 on top of patchback/backports/3.13/86a9a3827c876acfd32886bd51b49df7f5f1925e/pr-11148 Backporting merged PR #11148 into master
🤖 @patchback |
(cherry picked from commit 86a9a38)
(cherry picked from commit 86a9a38)
(cherry picked from commit 86a9a38)
…n ssl_shutdown_timeout is 0 (#11156)
…n ssl_shutdown_timeout is 0 (#11155)
What do these changes do?
This PR improves SSL connection handling by changing the default
ssl_shutdown_timeout
from 0.1 to 0, providing the best of both worlds:Additionally, this PR:
ssl_shutdown_timeout=0
on all Python versions. Previously, this value was rejected on Python 3.11+ and ignored on earlier versions.ssl_shutdown_timeout
parameter for removal in aiohttp 4.0, as there's no clear use case for users to change the default behaviorKey changes:
ssl_shutdown_timeout
is now0
(immediate abort on connector close) instead of0.1
secondsssl_shutdown_timeout=0
now works on all Python versions and will immediately abort SSL connections usingtransport.abort()
instead oftransport.close()
when the connector is closedssl_shutdown_timeout=0
, the value is not passed toloop.create_connection()
orloop.start_tls()
to avoid rejection by asyncioRuntimeWarning
is issued when non-zero values are passed on Python < 3.11, informing users that onlyssl_shutdown_timeout=0
is supported on older Python versionsDeprecationWarning
is issued when any value is explicitly passed forssl_shutdown_timeout
, indicating the parameter will be removed in aiohttp 4.0Are there changes in behavior for the user?
ssl_shutdown_timeout=0
for immediate abort on connector closeRuntimeWarning
if they attempt to use non-zerossl_shutdown_timeout
values on Python < 3.11DeprecationWarning
when explicitly settingssl_shutdown_timeout
, as this parameter will be removed in aiohttp 4.0ssl_shutdown_timeout=0.1
(on Python 3.11+) until the parameter is removedIs it a substantial burden for the maintainers to support this?
No, this is a minimal maintenance burden:
Related issue number
closes #11144
Checklist
CONTRIBUTORS.txt
CHANGES/
foldername 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 animproper 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 breakingchanges 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 buildprocess.
.packaging
: Notes for downstreams about unobvious side effectsand 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 abovecategories.
Make sure to use full sentences with correct case and punctuation,
for example:
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.