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
Don't cache Bookie hostname DNS resolution forever #1762
Conversation
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.
Okay.
+1 for not adding tests, it will very tricky
But we should add a comment, in the future people could think it will be a good idea to cache the value and undo this patch
Good point, I'll add comment. In future we should try to move to use async DNS from Netty instead of relying on the blocking DNS resolution from JDK + OS. We've been using that in Pulsar for 1 year now and it has been working very well. |
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.
I think unit testing would be hard. Should be possible with an integration test, but I'm not sure if it's worth it.
@eolivelli Added comment |
LGTM but you also need to consider effects of
|
@dlg99 In any case, the current behavior is caching the DNS resolution forever in the BK client process. That comes before reaching the JVM DNS cache or the OS DNS cache. By creating new instances of (BTW: I think the JVM cache is a bad thing on its own, but that's a different story... :) ) |
run integration tests |
IGNORE IT CI |
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.
+1
Looks good. Thanks
### Motivation `BookieSocketAddress` is resolving the bookie DNS name in its constructor and then using the already resolved `InetSocketAddress` instance. If the IP of a bookie changes, the BK client will continue to use the old IP address. ### Changes Construct a new `InetSocketAddress` each time `getSocketAddress()` gets called (eg: each time we attempt to make a new connection) so that we're making sure to get the right IP. I cannot think of a good way to add unit test for this at this point, suggestions are welcome. I think this should be included in a patch release as well 4.7.3 or 4.8.1 Reviewers: Andrey Yegorov <None>, Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org>, Ivan Kelly <ivank@apache.org> This closes #1762 from merlimat/fix-dns (cherry picked from commit 3d8bad4) Signed-off-by: Sijie Guo <sijie@apache.org>
### Motivation `BookieSocketAddress` is resolving the bookie DNS name in its constructor and then using the already resolved `InetSocketAddress` instance. If the IP of a bookie changes, the BK client will continue to use the old IP address. ### Changes Construct a new `InetSocketAddress` each time `getSocketAddress()` gets called (eg: each time we attempt to make a new connection) so that we're making sure to get the right IP. I cannot think of a good way to add unit test for this at this point, suggestions are welcome. I think this should be included in a patch release as well 4.7.3 or 4.8.1 Reviewers: Andrey Yegorov <None>, Enrico Olivelli <eolivelli@gmail.com>, Sijie Guo <sijie@apache.org>, Ivan Kelly <ivank@apache.org> This closes #1762 from merlimat/fix-dns
merged to master, branch-4.8 and branch-4.7 |
Motivation
BookieSocketAddress
is resolving the bookie DNS name in its constructor and then using the already resolvedInetSocketAddress
instance.If the IP of a bookie changes, the BK client will continue to use the old IP address.
Changes
Construct a new
InetSocketAddress
each timegetSocketAddress()
gets called (eg: each time we attempt to make a new connection) so that we're making sure to get the right IP.I cannot think of a good way to add unit test for this at this point, suggestions are welcome.
I think this should be included in a patch release as well 4.7.3 or 4.8.1