-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpClient] Dns cache issue in long running process #43929
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
Comments
Symfony 5.4 will provide your 2nd solution: #41163 We could also remove the entry from the DNS cache when a transport error happens at connection time. Would you like to give it a try? |
@nicolas-grekas Symfony 5.4 will not provide that second solution, as the http_client service will not reset its DNS cache when resetting services. And the reason why the attempt at doing the second solution does not work is because the symfony/src/Symfony/Component/DependencyInjection/Compiler/DecoratorServicePass.php Lines 104 to 105 in 0abd898
|
Won't #43333 still forward the call to reset? |
@nicolas-grekas I can help with PR, which branch should I target? |
I'd say 5.4 please |
Actually, |
As I mentioned in my first message, I'm using a
Totally different problem which I found is that
cc @nicolas-grekas maybe you will have more insights or corrections if I'm wrong at some point |
@nicolas-grekas I managed to reproduce an issue with wrongly resolved Take a look at https://github.com/rmikalkenas/dns-cache-issue/blob/master/src/Command/HttpClientCommand.php Tried to add
to reset method and explicitly call it after first request |
…dle on reset (rmikalkenas) This PR was submitted for the 5.4 branch but it was merged into the 4.4 branch instead. Discussion ---------- [HttpClient] Curl http client has to reinit curl multi handle on reset | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #43929 | License | MIT All the details are described in #43929 Commits ------- dc4380f [HttpClient] Curl http client has to reinit curl multi handle on reset
Uh oh!
There was an error while loading. Please reload this page.
Symfony version(s) affected
5.3.10
Description
Recently came up with very interesting bug or I would say a side affect of symfony http client using in a long running process:
I have a long running process which consumes async envelopes and does http requests to constant host (process might run up to couple of hours). At some point of time the host which we are requesting changed its IP address and therefore my consumer process started to fail to send http requests. After a brief investigation I have found out that symfony's http client has an dns cache in its base clients (CurlHttpClient, NativeHttpClient) and it only resets on class destruction.
I do understand why this dns cache is implemented on http client, but looks like it might be a bottleneck for a long running process.
I could help with a possible fix and PR preparation, but need more insights on this issues
How to reproduce
My environment:
Php version:
7.4.21
Curl version:
7.64.0
Symfony version:
5.3.10
http_client.yaml configuration:
under the hood using
CurlHttpClient
all the services injecting http client by using
Symfony\Contracts\HttpClient\HttpClientInterface
typehinthave a long running process which does http requests to same host using symfony http client
DNS changes host ip
the same long running process's requests start to fail (due to using old ip)
Possible Solution
kernel.reset
tag forCurlHttpClient
and make sure that with every handled envelope theServicesResetter
would be called. I even tried to do it locally, but without luck.. What I tried:vendor/symfony/framework-bundle/Resources/config/http_client.php
http_client
definition added->tag('kernel.reset', ['method' => 'reset'])
with a hope that it would be included toServicesResetter
, but as I'm having a retry configuration (see on reproduce tab) thehttp_client
service at some point is removed from container and replaced with decoratedhttp_client.retryable
(see screenshot in additional context) service and thishttp_client.retryable
gets kernel.rest tag, but unfortunately it does not work as it doesnt implement ResetInterface. If I remove retry configuration, then it works fine.Additional Context
The text was updated successfully, but these errors were encountered: