Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

minwoox
Copy link
Contributor

@minwoox minwoox commented Feb 11, 2025

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:

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
@minwoox minwoox added the defect label Feb 11, 2025
@minwoox minwoox added this to the 1.32.0 milestone Feb 11, 2025
@minwoox
Copy link
Contributor Author

minwoox commented Feb 11, 2025

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);
Copy link
Contributor Author

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 {
Copy link
Contributor

@jrhee17 jrhee17 Feb 12, 2025

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

Suggested change
final class CacheEntry {
static final class CacheEntry {

Copy link
Contributor Author

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. 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebClient resolver doing eventloop-work on worker
3 participants