GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactor DnsNameResolver to be able to use different strategies when … by normanmaurer · Pull Request #14374 · netty/netty

Conversation

@normanmaurer

@normanmaurer normanmaurer commented Sep 26, 2024

Copy link
Copy Markdown
Member

…it comes to creating Channels for queries.

Motivation:

At the moment we reuse the same Channel (and so underyling socket) for all queries. It has show that this can cause problems in some deployments, we should allow to use different strategies.

Modifications:

  • Refactor code to make it possible to use different strategies when it comes to creating / reusing channels for resolve operations

Result:

More flexible configuration and possible fix for #14364

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@normanmaurer
normanmaurer marked this pull request as draft September 26, 2024 15:01
@normanmaurer
normanmaurer requested review from chrisvest and idelpivnitskiy September 26, 2024 15:01
@normanmaurer

normanmaurer commented Sep 26, 2024

Copy link
Copy Markdown
Member Author

Just to show the idea... This still lacks the possibility to configure the different strategies (at the moment it just creates a new socket per resolve operation). That said it would be easy to expose some enum to allow to configure it via the builder (not sure what the default should be tho).

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer mentioned this pull request Sep 26, 2024
Netty issue with DNS resolution in Kubernetes environment #14364
Open
@normanmaurer
normanmaurer requested a review from bryce-anderson September 26, 2024 15:02
normanmaurer
normanmaurer commented Sep 26, 2024
View reviewed changes
Comment thread resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer commented Sep 26, 2024
View reviewed changes
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

idelpivnitskiy
idelpivnitskiy reviewed Sep 26, 2024
View reviewed changes
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsAddressResolveContext.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Outdated

@idelpivnitskiy idelpivnitskiy Sep 26, 2024

Copy link
Copy Markdown
Member

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.

There was a fix #14147 that made default caches sharable between resolvers. Also if users configure their own caches, they are also sharable. Why do we clear them here? If only 1 out of N resolvers gets closed, it will affect a shared cache across remaining N-1 resolvers.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Sep 26, 2024

Copy link
Copy Markdown
Member Author

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.

We always did so unjust preserved it

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Sep 27, 2024

Copy link
Copy Markdown
Member Author

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.

let me do another PR for this

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

idelpivnitskiy reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/TcpDnsQueryContext.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer force-pushed the dns_ref branch from fe8f6ea to 67208e2 Compare September 27, 2024 07:36
@normanmaurer
normanmaurer requested a review from idelpivnitskiy September 27, 2024 10:14
normanmaurer
normanmaurer commented Sep 27, 2024
View reviewed changes
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverChannelStrategy.java
/**
* Strategy that influence how {@link io.netty.channel.socket.DatagramChannel}s are used during queries.
*/
public enum DnsNameResolverChannelStrategy {

@normanmaurer normanmaurer Sep 27, 2024

Copy link
Copy Markdown
Member Author

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.

@idelpivnitskiy @bryce-anderson @chrisvest I am open for better ideas related to naming...

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@idelpivnitskiy idelpivnitskiy Sep 27, 2024

Copy link
Copy Markdown
Member

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.

If you ever anticipate reusing this strategy for TCP (especially if we ever make it possible to create a TCP-only resolver), then name lgtm, just adjust the javadoc to avoid mentioning DatagramChannel. Imho, we can mention DatagramChannel on the builder method instead of this enum.

If you expect to have 2 different enums for UDP/TCP in the future, then consider renaming this one to DnsNameResolverDatagramChannelStrategy.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@bryce-anderson bryce-anderson Sep 27, 2024

Copy link
Copy Markdown
Contributor

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.

wdyt about DnsNameResolverSocketStrategy? The one-to-one relationship between channel and socket is perhaps well known enough for the Netty level, but Socket is the actual behavior difference we want to achieve and the fact that it's different channels is just an implementation detail.

For the enum values, how about

SocketPerResolver and SocketPerResolution? I like how they're more descriptive but don't like how they're so close and could be mistaken at a glance so I'm not sold on them myself.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Sep 30, 2024

Copy link
Copy Markdown
Member Author

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.

PTAL again @bryce-anderson I think I like this name more.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
idelpivnitskiy
idelpivnitskiy reviewed Sep 27, 2024
View reviewed changes
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverChannelStrategy.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/TcpDnsQueryContext.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverChannelStrategy.java
/**
* Strategy that influence how {@link io.netty.channel.socket.DatagramChannel}s are used during queries.
*/
public enum DnsNameResolverChannelStrategy {

@idelpivnitskiy idelpivnitskiy Sep 27, 2024

Copy link
Copy Markdown
Member

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.

If you ever anticipate reusing this strategy for TCP (especially if we ever make it possible to create a TCP-only resolver), then name lgtm, just adjust the javadoc to avoid mentioning DatagramChannel. Imho, we can mention DatagramChannel on the builder method instead of this enum.

If you expect to have 2 different enums for UDP/TCP in the future, then consider renaming this one to DnsNameResolverDatagramChannelStrategy.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer normanmaurer added this to the 4.1.114.Final milestone Sep 30, 2024
@normanmaurer
normanmaurer marked this pull request as ready for review September 30, 2024 09:07
@normanmaurer
normanmaurer requested a review from idelpivnitskiy September 30, 2024 10:08
normanmaurer
normanmaurer commented Sep 30, 2024
View reviewed changes
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsQueryContext.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer
normanmaurer force-pushed the dns_ref branch from 80930e7 to fead947 Compare September 30, 2024 10:10
idelpivnitskiy
idelpivnitskiy approved these changes Sep 30, 2024
View reviewed changes
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverBuilder.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolverChannelStrategy.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Outdated

@idelpivnitskiy idelpivnitskiy Sep 30, 2024

Copy link
Copy Markdown
Member

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.

side note: why does PromiseNotifier.cascade(f, promise) does not check that f is already done before adding a listener?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@normanmaurer
normanmaurer force-pushed the dns_ref branch from 1834c3b to 4000c02 Compare September 30, 2024 12:48
@normanmaurer

normanmaurer commented Sep 30, 2024

Copy link
Copy Markdown
Member Author

One sec there is something wrong I need to fix first...

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@normanmaurer

normanmaurer commented Sep 30, 2024

Copy link
Copy Markdown
Member Author

@bryce-anderson @idelpivnitskiy ok this is ready to go now

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer and others added 3 commits September 30, 2024 20:10
@normanmaurer @idelpivnitskiy
Refactor DnsNameResolver to be able to use different strategies when …
3a7b939
…it comes to creating Channels for queries.

Motivation:

At the moment we reuse the same Channel (and so underyling socket) for all queries. It has show that this can cause problems in some deployments, we should allow to use different strategies.

Modifications:

- Refactor code to make it possible to use different strategies when it comes to creating / reusing channels for resolve operations

Result:

More flexible configuration and possible fix for #14364

Co-authored-by: Idel Pivnitskiy <[email protected]>
@normanmaurer
add ignore
9de62e3
@normanmaurer
done
ebbd956
@normanmaurer
normanmaurer force-pushed the dns_ref branch from fc9072c to ebbd956 Compare September 30, 2024 18:10
idelpivnitskiy
idelpivnitskiy approved these changes Sep 30, 2024
View reviewed changes
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

bryce-anderson
bryce-anderson approved these changes Sep 30, 2024
View reviewed changes

@bryce-anderson bryce-anderson left a comment

Copy link
Copy Markdown
Contributor

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 left some simplification suggestions but it looks correct to me.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/main/java/io/netty/resolver/dns/DnsNameResolver.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread resolver-dns/src/test/java/io/netty/resolver/dns/DnsNameResolverTest.java

private static DnsNameResolverBuilder newResolver(boolean decodeToUnicode) {
return newResolver(decodeToUnicode, null);
private static DnsNameResolverBuilder newResolver(DnsNameResolverChannelStrategy strategy,

@bryce-anderson bryce-anderson Sep 30, 2024

Copy link
Copy Markdown
Contributor

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.

In my minds eye we can (should?) run all tests with each strategy. Instead of making nearly all tests parameterized, could we instead make the test suite abstract and pass in a strategy as part of the constructor, then make two a new concrete class for each strategy that passes in the correct enum value?

That would require the private static DnsResolverType newResolver(..) family of methods to no longer be static but that seems like a smaller changeset than this.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@normanmaurer normanmaurer Oct 1, 2024

Copy link
Copy Markdown
Member Author

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.

This is not possible with Junit5 :( junit-team/junit-framework#878

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
normanmaurer added 2 commits October 1, 2024 08:28
@normanmaurer
Simplify
20ce98b
@normanmaurer
Simplify
c7c7a0d
@normanmaurer
Address comments and simplify
3e4187a
idelpivnitskiy
idelpivnitskiy approved these changes Oct 1, 2024
View reviewed changes
@normanmaurer
normanmaurer merged commit d5f4bfb into 4.1 Oct 1, 2024
@normanmaurer
normanmaurer deleted the dns_ref branch October 1, 2024 09:20
normanmaurer added a commit that referenced this pull request Oct 1, 2024
@normanmaurer @idelpivnitskiy
Refactor DnsNameResolver to be able to use different strategies when … (
ff3a098
#14374)

…it comes to creating Channels for queries.

Motivation:

At the moment we reuse the same Channel (and so underyling socket) for
all queries. It has show that this can cause problems in some
deployments, we should allow to use different strategies.

Modifications:

- Refactor code to make it possible to use different strategies when it
comes to creating / reusing channels for resolve operations

Result:

More flexible configuration and possible fix for
#14364

---------

Co-authored-by: Idel Pivnitskiy <[email protected]>
@normanmaurer normanmaurer mentioned this pull request Oct 1, 2024
Refactor DnsNameResolver to be able to use different strategies when … #14382
Merged
normanmaurer added a commit that referenced this pull request Oct 2, 2024
@normanmaurer @idelpivnitskiy
Refactor DnsNameResolver to be able to use different strategies when … (
9ff63a5
#14382)

…… (#14374)

…it comes to creating Channels for queries.

Motivation:

At the moment we reuse the same Channel (and so underyling socket) for
all queries. It has show that this can cause problems in some
deployments, we should allow to use different strategies.

Modifications:

- Refactor code to make it possible to use different strategies when it
comes to creating / reusing channels for resolve operations

Result:

More flexible configuration and possible fix for
#14364

Co-authored-by: Idel Pivnitskiy <[email protected]>
This was referenced Sep 14, 2026
Http2: Reserve promised stream for PUSH_PROMISE after local RST_STREAM #17471
Closed
cache failure 1233e4a5 #17565
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bryce-anderson bryce-anderson bryce-anderson approved these changes
@idelpivnitskiy idelpivnitskiy idelpivnitskiy approved these changes
@chrisvest chrisvest Awaiting requested review from chrisvest

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.1.114.Final

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@normanmaurer @bryce-anderson @idelpivnitskiy
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.