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

Run fixLowPeers on startup #694

Merged

Conversation

samsondav
Copy link
Contributor

@samsondav samsondav commented Sep 8, 2020

The git diff makes this look more invasive than it really is.

All I did was pull some logic out of fixLowPeersRoutine into a separate function and make it public. None of the functionality has been changed.

@aschmahmann
Copy link
Contributor

@samsondav this is exposing a fairly internal function that is subject to change. What are you hoping to use it for? Are you just trying to make sure that it's called at startup, if so there are some other options available to us including:

  1. Just making it always run on startup
  2. Having an option to make it run on startup
  3. Have Bootstrap call fixRTIfNeeded

@samsondav
Copy link
Contributor Author

We need it to run on startup, since we immediately query the DHT after instantiating it and we get "no peers found" error even though we provided bootstrap nodes.

@samsondav
Copy link
Contributor Author

What do you think the best way to solve this problem is?

@aschmahmann
Copy link
Contributor

I'm not sure offhand which of these three options is the best, although I suspect that having it always run on startup makes the most sense.

@petar sound like a plan?

@petar
Copy link
Contributor

petar commented Sep 10, 2020

I would have chosen adding as part of Bootstrap. So that at API level there is a clear contract that routing operations work after invoking a Bootsrap.

@samsondav
Copy link
Contributor Author

@petar @aschmahmann I added it to Bootstrap, what do you think?

Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

Seems good, just a couple comments to change and we're good to go. Thanks for the PR 😄

dht.go Outdated Show resolved Hide resolved
@samsondav
Copy link
Contributor Author

@petar commented this:

FixLowPeers should be called and finish strictly before RefreshManager starts. We can hook this up.
Concurrent user calls to Bootstrap (which will also invoke FixLowPeers) should be ok.

(pasted from slack convo)

@samsondav samsondav force-pushed the bootstrap_connect_on_startup branch from 1577b8e to 099c43e Compare September 17, 2020 11:16
Copy link
Contributor

@petar petar left a comment

Choose a reason for hiding this comment

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

fixLowPeers must be syncronized with refresh manager trigger

dht_bootstrap.go Outdated Show resolved Hide resolved
dht.go Outdated Show resolved Hide resolved
@samsondav
Copy link
Contributor Author

@petar @aschmahmann I've updated it based on your most recent comments, would you mind taking another look?

Copy link
Contributor

@aschmahmann aschmahmann left a comment

Choose a reason for hiding this comment

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

Thanks for doing this and apologies for the delayed review. Left a couple small change requests and a question.

dht.go Show resolved Hide resolved
Comment on lines +420 to +422
if err := dht.rtRefreshManager.Start(); err != nil {
logger.Error(err)
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not put this in a separate goprocess and leave it in the init function, it's nice to return the errors on init since if we fail to start the refresh manager the DHT is dead. A log error, isn't nearly as good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is contrary to what @petar said above:

FixLowPeers should be called and finish strictly before RefreshManager starts

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah fair enough, for now this may to reduce start up errors from refreshing the routing table while it's still empty.

However, calling host.Connect() on a bootstrap peer will not actually add the peer to the routing table immediately as that's triggered by a separate event. If we want to reduce those errors we'll have to add something that actually waits on peers initially being added to the routing table.

dht.go Show resolved Hide resolved
dht.go Show resolved Hide resolved
@aschmahmann aschmahmann changed the title Allow external clients to call FixLowPeers manually Run fixLowPeers on startup Oct 20, 2020
@aschmahmann aschmahmann merged commit dfa5d46 into libp2p:master Oct 20, 2020
@aschmahmann aschmahmann mentioned this pull request Feb 18, 2021
73 tasks
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.

3 participants