-
Notifications
You must be signed in to change notification settings - Fork 910
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
Allow configuring DefaultAddressResolverGroup by flag #2261
Conversation
Motivation: Domain name resolution failure was reported on Windows OS line#2243 Before solving the origin problem, this workaround enables [`DefaultAddressResolverGroup`](https://netty.io/4.1/api/io/netty/resolver/class-use/DefaultAddressResolverGroup.html) by default for Windows OS. The `DefaultAddressResolverGroup` uses JDK's built-in domain name lookup mechanism. See [here](https://netty.io/4.1/api/io/netty/resolver/DefaultNameResolver.html) for more information. Modification: * Add `useDefaultDnsResolver` flag to enable `DefaultAddressResolverGroup` by default for Windows OS * Register DefaultAddressResolverGroup.INSTANCE if it is possible. Result: A user who runs Armeria on Windows OS can now use `DefaultAddressResolverGroup` for domain name resolution by default.
Codecov Report
@@ Coverage Diff @@
## master #2261 +/- ##
============================================
- Coverage 73.6% 73.56% -0.05%
+ Complexity 9807 9802 -5
============================================
Files 859 859
Lines 37721 37727 +6
Branches 4648 4649 +1
============================================
- Hits 27766 27754 -12
- Misses 7578 7599 +21
+ Partials 2377 2374 -3
Continue to review full report at Codecov.
|
Looking at the linked doc this seems to do blocking I/O - so I think we'd have to do more refactoring to use blocking executor. Not sure if it's worth it without getting more reports. I guess with Windows it's easy to enable the firewall on your app which could block udp packets coming back |
When I was implementing this logic(yesterday), I also read the documentation and got advice from @trustin. @trustin Could you tell us why we don't need to change the given executor? 🙏 |
Had talked with @trustin. I'm still wondering if it is worth implementing? Because DNS is cacheable, we will fix the original issue on the next step. |
The performance might be ok - we'd need to verify that it's not possible to deadlock. I'm not sure what would happen if a client and DNS request use the same event loop, but I have seen deadlock when blocking the event loop during a client request so I'm very scared of doing it. I might rethink whether this is really needed (I'm currently assuming we've only had one report, the attached one, which might not indicate such a big hammer but if there are more you know about then it might be), but even if adding I'd recommend not making it default. Tests working on appveyor (and my laptop and GitHub's Azure VMs :) ) I think give us reasonable confidence in our current defaults |
Just curious, Could you explain to me how blocking causes deadlock? 😀 |
I've seen it here - https://github.com/openzipkin/zipkin/pull/2703/files It happens when a client request is made in a blocking way from a server request - if the client and server request are being handled by the same event loop, the client will wait for I/O forever while the server has blocked the event loop waiting for the client request to finish. I'm not sure if the same is an issue in this case, but it makes me very nervous :) |
Could you take a DNS test for http://echo.jsontest.com and http://json.org ? If you can test it on your CI and laptop, I want to get your result. 😀
We have discussed Windows domain resolution issue and decided to divide this into 3 steps. 1st step
If this is fine, we could merge this PR after turning off the flag. If you don't agree with the blocking operation even though it turns off the default option, I will fork Netty DefaultAddressResolverGroup and fetch it to run domain resolution with a given executor. 🛠 2nd step
3th step
|
I think that looks fine since we don't change the default without more investigation. Only thing I'd add is for 2nd step, if changing the default also be sure that the blocking won't cause deadlock. I guess it won't - the pattern is probably doing one more I/O after the block which wouldn't happen since DNS is the lowest level possible - but want to be confidence since it's very confusing to debug |
That sounds good to me. When we need to change the default, I will change the default DNS resolver to run with blocking executor. 👍 |
Updated:
|
7290b4e
to
ae2a7f7
Compare
ae2a7f7
to
d848698
Compare
import org.junit.jupiter.api.condition.DisabledIfSystemProperty; | ||
import org.junit.jupiter.api.condition.EnabledIfSystemProperty; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for education :-)
core/src/main/java/com/linecorp/armeria/client/ClientFactoryBuilder.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice work, @ikhoon!
Motivation: Domain name resolution failure was reported on Windows OS. line#2243 Before solving the original problem, this workaround enables [`DefaultAddressResolverGroup`](https://netty.io/4.1/api/io/netty/resolver/class-use/DefaultAddressResolverGroup.html) by the flag. This flag is disabled by default. The `DefaultAddressResolverGroup` uses JDK's built-in domain name lookup mechanism. See [here](https://netty.io/4.1/api/io/netty/resolver/DefaultNameResolver.html) for more information. Modification: * Add `useJdkDnsResolver` flag to enable `DefaultAddressResolverGroup`. * Use `DefaultAddressResolverGroup.INSTANCE` if it is possible. Result: A user can now use `DefaultAddressResolverGroup` by enabling `useJdkDnsResolver` flag.
Motivation:
Domain name resolution failure was reported on Windows OS. #2243
Before solving the original problem, this workaround enables
DefaultAddressResolverGroup
by the flag. This flag is disabled by default.The
DefaultAddressResolverGroup
uses JDK's built-in domain name lookup mechanism. See here for more information.Modification:
useJdkDnsResolver
flag to enableDefaultAddressResolverGroup
.DefaultAddressResolverGroup.INSTANCE
if it is possible.Result:
A user can now use
DefaultAddressResolverGroup
by enablinguseJdkDnsResolver
flag.