-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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 infinite callback loop when time is not moving forward #10151
Conversation
If the keepalive handler is called too soon, it reschedules itself. The test used `now <= close_time`, which means that an exactly on-time notification is treated as "too soon", causing an automatic rescheduling. For real systems the time will eventually advance and break the loop, but with async-solipsism, time doesn't advance until there is some reason to sleep and the loop is infinite. Closes aio-libs#10149.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #10151 +/- ##
=======================================
Coverage 98.75% 98.75%
=======================================
Files 122 122
Lines 36954 36997 +43
Branches 4411 4413 +2
=======================================
+ Hits 36494 36538 +44
Misses 313 313
+ Partials 147 146 -1
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 #10151 will not alter performanceComparing Summary
|
We need to make this very clear it's not a production problem so we don't end up with unexpected questions or discussions. Additionally we haven't committed to supporting async-solipsism at this time so I changed the title to better reflect that. |
I think we should change the fragment to packaging instead of bugfix since it's for testing and doesn't affect production |
Is there any chance of a regression test without adding a new dependency? |
I think a test could be added using |
Sure, I'll do that. But are you sure aiohttp isn't used in any environment in which the timer precision might be low enough that it causes the event to be re-scheduled unnecessarily (which won't be an infinite loop, but will cause more work than necessary)? I'm thinking of environments that deliberately degrade timer precision to prevent Spectra-type side-channel attacks.
From what I've seen, I've never tested async-solipsism on non-Linux OSes, so it might not be something you want the test suite to depend on at this point. |
That seems unlikely as we haven't had any issue reports, and even
We don't have any maintainers familiar with it either so its not something we could effectively troubleshoot so we wouldn't want to depend on it right now. |
At request of @bdraco
I think we only need to patch |
I'm not so sure — it doesn't touch any packaging metadata / mechanisms / downstream expectations. This would be misleading, in my opinion. I suppose, we could go for But yeah, a regression test would be most welcome here... |
|
Ok, renamed to |
I added a test to ensure the keep alive expires on time. I don't love it, but since |
Backport to 3.11: 💚 backport PR created✅ Backport PR branch: Backported as #10173 🤖 @patchback |
Co-authored-by: J. Nick Koston <nick@koston.org> (cherry picked from commit 7c12b1a)
Backport to 3.12: 💚 backport PR created✅ Backport PR branch: Backported as #10174 🤖 @patchback |
Co-authored-by: J. Nick Koston <nick@koston.org> (cherry picked from commit 7c12b1a)
What do these changes do?
If the keepalive handler is called too soon, it reschedules itself. The test used
now <= close_time
, which means that an exactly on-time notification is treated as "too soon", causing an automatic rescheduling. For real systems the time will eventually advance and break the loop, but with async-solipsism, time doesn't advance until there is some reason to sleep and the loop is infinite.Are there changes in behavior for the user?
This will fix infinite loops when using async-solipsism.
Is it a substantial burden for the maintainers to support this?
No. This does not increase the amount of code at all.
Related issue number
Fixes #10149.
Checklist
CONTRIBUTORS.txt
(already there)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.