threads: force connect when adding thread #109
Merged
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.
@sanderpick , here's a PR to show a bug that I'd like your confirmation.
The current PR has the fix, but let me explain the situation.
If you run
TestE2EWithThreads
test (with boostrap commented as shown) without the patch here showed inthreads.go
, the test fail with:store_test.go:65: rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing failed to find any peer in table"
If you re-enable boostrap in the test, the test pass OK.
From a conceptual POV, this didn't made sense. Why I would need to boostrap with cafes (since are the defaults now) to let two peers sync to each other, where one of them joined with a thread link?
Was quite hard to figure out since the error was too generic and didn't give a clue on where was the problem.
The problem was in
lgs, err := t.service.getLogs(ctx, id, pid)
, just below the patch I did inthreads.go
. The problem there was that the gRPC connection failed since it doesn't know how to resolve the peer.ID addrs.What I added was to explicitly connect to the peer corresponding to the Thread link, so to avoid that problem. This solves the problem... now unboostrapped peers sync correctly.
I wanted to know your opinion... this seems reasonable to me, since why not connect to the peer of the thread link?. But I'm not sure that is the right place, or something else should have done this job correctly. The good part is that is easy to reproduce: take this PR, and comment only the changes in
thread.go
, thengo run ./eventstore -run TestE2EWithThreads
.