Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Periodic Pinging and active fixLowPeers #533

Merged
merged 2 commits into from
Apr 3, 2020

Conversation

aarshkshah1992
Copy link
Contributor

@aarshkshah1992 aarshkshah1992 commented Apr 2, 2020

@aschmahmann

For #521 and makes fixLowPeers more active.

RT peer at libp2p/go-libp2p-kbucket#69.

@@ -125,7 +125,10 @@ func handlePeerIdentificationCompletedEvent(dht *IpfsDHT, e event.EvtPeerIdentif
return
} else if valid {
dht.peerFound(dht.ctx, e.Peer, false)
dht.fixLowPeers()
select {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we put this in a function?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

dht.go Outdated
@@ -181,6 +188,10 @@ func New(ctx context.Context, h host.Host, options ...Option) (*IpfsDHT, error)
// go-routine to make sure we ALWAYS have RT peer addresses in the peerstore
// since RT membership is decoupled from connectivity
go dht.persistRTPeersInPeerStore()

// listens to the fix low peers chan and tries to fix the Routing Table
go dht.fixLowPeersRoutine()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

later: given that we're using goprocess, let's manage this with goprocess.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

dht_bootstrap.go Outdated
for _, ps := range dht.routingTable.GetPeerInfos() {
// ping the peer if it's due for a ping and evict it if the ping fails
if time.Since(ps.LastSuccessfulOutboundQuery) > dht.maxLastSuccessfulOutboundThreshold {
livelinessCtx, cancel := context.WithTimeout(ctx, 10*time.Second)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a constant?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// ping Routing Table peers that haven't been hear of/from in the interval they should have been.
for _, ps := range dht.routingTable.GetPeerInfos() {
// ping the peer if it's due for a ping and evict it if the ping fails
if time.Since(ps.LastSuccessfulOutboundQuery) > dht.maxLastSuccessfulOutboundThreshold {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not treating this as a successful query. I think we need to record a separate "last seen"? Otherwise, we'll keep re-connecting once the peer hits this limit.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, this is not needed for now as we will probably evict flaky-connectivity peers from the DHT because they wont respond back to us with good latencies. Please see #536 for more details.

@aarshkshah1992
Copy link
Contributor Author

aarshkshah1992 commented Apr 3, 2020

@Stebalien I have addressed all the review comments and am merging this because of the approval. Lmk if concerns crop up and I'll address them in a new PR.

@aarshkshah1992 aarshkshah1992 merged commit b0b69cc into cypress Apr 3, 2020
Stebalien pushed a commit that referenced this pull request Apr 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants