fix(bitswap): see peers connected before startup - #1201
Open
lidel wants to merge 1 commit into
Open
Conversation
Start registers a libp2p notifier, which only reports connections opened from then on, and never looks at the ones already open. A peer connected while the node was still being built therefore stayed disconnected as far as Bitswap was concerned, for the whole life of that connection: it was never sent a want, and nothing later corrected the record. Callers with routing configured usually found the content another way, so this surfaced as an occasional hang on nodes that had nothing else to fall back on. Take stock of the open connections after registering the notifier, so a connection opening right at that moment is counted twice at worst, which the event manager already handles.
Codecov Report❌ Patch coverage is
@@ Coverage Diff @@
## main #1201 +/- ##
==========================================
+ Coverage 63.87% 63.89% +0.01%
==========================================
Files 269 269
Lines 27144 27148 +4
==========================================
+ Hits 17339 17346 +7
+ Misses 8095 8090 -5
- Partials 1710 1712 +2
... and 12 files with indirect coverage changes 🚀 New features to boost your workflow:
|
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.
Note
This mainly aims to remove flakes from CI tests in kubo (found as part of ipfs/kubo#11413)
Problem
Bitswap can wait forever for a block a connected peer already has.
Startregisters a libp2p notifier, and libp2p only reports connections opened after that, so a peer connected while the node is still coming up is never recorded. Bitswap never sends it a want, and nothing corrects that later: the peer stays invisible for the life of the connection. Routing usually hides this by finding the content elsewhere; without that fallback the fetch just hangs. It surfaced as Kubo'skubo-as-a-libraryexample timing out in CI, where mDNS connects the two nodes while one is still starting.Fix
ConnectedignoresThis closes the startup window for every embedder, not just Kubo. Nothing changes about how peers are dropped or re-added later. Separate from #1163: that one lost a peer it had already seen, this one never sees it at all.