-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
singleInFlight can cause all future DNS requests to fail #1449
Comments
I somewhat feel the whole SingleInflight code is too fragile and we might be better off removing it. It also has issues with contexts IIRC. It's also something callers can implement if they need it. |
[ Quoting ***@***.***> in "Re: [miekg/dns] singleInFlight can ..." ]
I somewhat feel the whole SingleInFligjt code is too fragile and we might be
better off removing it. It also has issues with contexts IIRC. It's also
something callers can implement if they need it.
Agreed, was a fun idea to add (10+ years ago), but too many subtle things.
I think we can noop the functionality?
|
amery
added a commit
to darvaza-proxy/resolver
that referenced
this issue
Dec 5, 2023
dns.Client.SingleInflight is a no-op. See github.com/miekg/dns/issues/1449 Signed-off-by: Alejandro Mery <amery@jpi.io>
amery
added a commit
to darvaza-proxy/resolver
that referenced
this issue
Dec 6, 2023
dns.Client.SingleInflight is a no-op. See github.com/miekg/dns/issues/1449 Signed-off-by: Alejandro Mery <amery@jpi.io>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently singleInFlight only takes into account the message and not the server address. I see the appeal because servers should return the same answer so why not group them. However, if a server is down then this has the unintentional consequence of causing all future DNS requests to fail.
Contrived example code
When running the above code you'll see:
Every query will forever fail despite only the second server being "down". This is because when it tries the first server a request to the second server is still timing out and then when it times out that goroutine tries the second server. The only way to get out of this is to wait for the second server to start working again or kill the program.
A simple fix would be to include the server's address in the group key. Alternatively,
exchangeWithConnContext
could check to see if the error returned fromDo
was for a different endpoint and immediately try again if so? But that could cause theExchange
function to take up to 2*Timeout which isn't ideal.Finally, when
SingleInflight
is true,Exchange
still callsDial
even if it will end up re-using an existing answer and just throwing away the connection without even using it. Any thoughts on tidying that up at the same time?The text was updated successfully, but these errors were encountered: