Run lookups after dial failure NET-384 - #216
Open
kalabukdima wants to merge 4 commits into
Open
Conversation
`addr_is_reachable` reads the variable on every call and Rust runs a binary's tests as threads in one process, so the test that set it decided what every concurrently running test saw. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The reconnect path fires on `ConnectionClosed`, while the address cache still holds the dead address, so it dials instead of looking the worker up. The dial then empties the cache and nothing re-arms: `reconnect_queue` is fed only by connection closures, and the whitelist sweep is suppressed while the registered set is unchanged. Part of NET-384 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The reconnect path fires only on ConnectionClosed, and at that point the address cache still holds the dead address, so it is dialed instead of looked up. That dial fails and evicts the entry, and nothing re-arms: a failed dial establishes no connection, so no close event follows, and the whitelist sweep is suppressed while the registered set is unchanged. The worker stayed undialable until unrelated DHT traffic happened to supply an address. NoAddresses is excluded deliberately -- it is the error a fruitless lookup produces, so scheduling on it would let recovery feed itself. Part of NET-384 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The current approach
After #199 the clients, e.g. pings collector, are trying to always keep connections to all workers open. This is a separate loop from actually sending the requests to them.
If a request is attempted and there is neither an existing connection nor known addresses of the peer, it just fails immediately. It doesn't trigger new Kademlia lookups because it assumes that the background loop already made the best effort to have that connection open.
The background loop works like this:
AddressCache.As a result
find_and_dialis rescheduled and the connection gets re-established.The issue
Every time the worker changes the address, it drops out of the healthy loop. At least until a happy coincidence returns it to the healthy loop, which usually takes >1h.
Why:
AddressCache::on_dial_failureevicts the entry. But nothing re-schedules the address lookup.no addresses for peer".The fix
The lookups are now scheduled on dial failures caused by unreachable addresses.
On the healthy loop, a stale address triggers a Kad query to get the worker reconnected if there is a reachable address in DHT.
Even if that peer is not reachable yet, it will keep retrying lookups every 30s because Kademlia keeps the last known address and won't evict it. Only if the peer completely drops out of Kademlia (
NoAddressespath), it gets dropped from the reconnect loop.