-
Notifications
You must be signed in to change notification settings - Fork 930
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
Fix a bug where an incorrect executor used for DNS refresh query #6092
base: main
Are you sure you want to change the base?
Conversation
Motivation: Each `CacheEntry` should be bound to a specific `RefreshingAddressResolver`, and the associated DNS refresh query must be executed using its own executor. However, there was a bug where the refresh query could be mistakenly executed by the executor of a different resolver accessing the same `CacheEntry`. Modifications: - Ensured that the DNS refresh query is always executed by the correct `RefreshingAddressResolver`'s executor. Result: - DNS refresh query is executed by the correct executor. - Close line#5891 line#6003
I couldn't make a test case for this. Please bear with me. 🙏 |
@@ -220,8 +221,7 @@ public void onRemoval(DnsQuestion question, @Nullable List<DnsRecord> records, | |||
final CacheEntry entry = addressResolverCache.getIfPresent(hostname); | |||
if (entry != null) { | |||
if (entry.refreshable()) { | |||
// onRemoval is invoked by the executor of 'dnsResolverCache'. | |||
executor().execute(entry::refresh); |
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.
refresh should be called by the entry's executor not by the executor who gets this cache entry from addressResolverCache
.
@@ -263,6 +263,7 @@ public void close() { | |||
|
|||
final class CacheEntry { |
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.
Note: It may make more sense that CacheEntry
is not bound to a specific resolver. Since there may be more changes involved, I'm fine with the current implementation
final class CacheEntry { | |
static final class CacheEntry { |
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.
The resolverClosed
flag is shared with CacheEntry
so I just couldn't make this class static. Let me try that later if we really need to. 😉
Motivation:
Each
CacheEntry
should be bound to a specificRefreshingAddressResolver
, and the associated DNS refresh query must be executed using its own executor. However, there was a bug where the refresh query could be mistakenly executed by the executor of a different resolver accessing the sameCacheEntry
.Modifications:
RefreshingAddressResolver
's executor.Result: