-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
curl_multi_select can return immediately ignoring timeout, with result 0 and error code 0 #2390
Labels
lifecycle/stale
No activity for a long time
Comments
Nyholm
added a commit
to Nyholm/guzzle
that referenced
this issue
Oct 27, 2019
This will fix guzzle#2390
Hey. Thank you for the bug report. I've made the patch you suggested. Could you please try if it works? |
Nyholm
added a commit
to Nyholm/guzzle
that referenced
this issue
Oct 27, 2019
This will fix guzzle#2390
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you for your contributions. |
Nyholm
added a commit
to Nyholm/guzzle
that referenced
this issue
Oct 9, 2020
This will fix guzzle#2390
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Guzzle version(s) affected: unknown
Description
The implementation of curl_multi_select changed in PHP 7.1.23/7.2.11 - It uses curl_multi_wait instead of curl_multi_select. See https://bugs.php.net/bug.php?id=76480
When this happens, requests will typically succeed, but spike to 100% cpu while waiting for requests to complete (because nothing is sleeping, not even curl_multi_select)
How to reproduce
This may only affect php >= 7.1.23 and curl >= 7.28.0. Use getAsync methods, where one endpoint takes a long time to respond (and another has a connect timeout). You may have to run this test repeatedly and log the number of times curl_multi_exec gets called.
Possible Solution
Call usleep(250 microseconds - microseconds elapsed since previous call to curl_multi_select ended) if curl_multi_select returns <= 0? A proposed fix to a different library is WordPress/Requests#284 - The symptoms seen prior to this is https://gist.github.com/TysonAndre/46a6829d9d8de00e50226890a6a9a63f (both curl_multi_select and curl_multi_exec return 0 but many times don't respect the configured timeout of 50 milliseconds)
Additional context
I observed that repeatedly calling curl_multi_select and curl_multi_exec
The guzzle implementation using curl_multi_select without handling a return value of 0 is:
https://github.com/guzzle/guzzle/blob/8f10d0e/src/Handler/CurlMultiHandler.php#L117-L130
The text was updated successfully, but these errors were encountered: