Repository navigation
Share DNS resolver group across connections. - #758
mdedetrich wants to merge 1 commit into
Conversation
ReactorNettyClient.connect(…) configured a new TcpClient per connection via resolver(Consumer), which creates a new DnsAddressResolverGroup on every call. Each group allocates a DNS resolver with its own UDP socket per event loop, and closing the connection never closes it, retaining one socket per connection. Cache one round-robin resolver group per LoopResources and preferNative setting, mirroring Reactor Netty's own resolver cache, so all connections share it. Extract TcpClient setup into createTcpClient(…) to verify resolver sharing.
|
Initially, we had 33287ab as motivation to move off our own resolver. Now, after applying a series of LLM-assisted pull requests that changed the general shape of this project to a worse state I am not convinced that throwing code at a problem until it seems to fix something previously unwanted while it is introducing a series of other problems, such as an anonymously keyed list holding on to static resources that never get cleaned up. In contrast, our previous balancer group might had suffered from other aspects yet it had well-defined retention model that was easier to discover. Therefore, we don't want to merge this change because it leads to harder to understand/maintain code. |
No worries, just wanted to help out since we had to revert to It is a bit surprising that the original LLM-assisted PR's (i.e. 33287ab) didn't pick regression that it ended up causing (this hasn't been my experience). |
Resolves #756.
Since #724,
ReactorNettyClient.connect(…)callsTcpClient.resolver(Consumer)per connection, which creates a newDnsAddressResolverGroupeach time. Closing the connection doesn't close the group, so every connection retains a DNS UDP socket.This caches one round-robin resolver group per
LoopResources/preferNative, mirroring Reactor Netty's own resolver cache, so all connections share it.TcpClientsetup is extracted intocreateTcpClient(…)so tests can assert that clients share the resolver; they fail against the previous code. Theconnect(…)diff is mostly that move.Verified with the reproduction from the issue (30 connect/close cycles by hostname): retained UDP sockets grow 10/20/30 before the change and plateau at 16 (one per event loop) after.
New Public APIs
None.