Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

Track timeouts per peer #274

Closed
wants to merge 7 commits into from
Closed

Track timeouts per peer #274

wants to merge 7 commits into from

Conversation

dirkmc
Copy link
Contributor

@dirkmc dirkmc commented Mar 2, 2020

@dirkmc
Copy link
Contributor Author

dirkmc commented Mar 2, 2020

@Stebalien let me know if this looks like the right approach

@Stebalien Stebalien self-requested a review March 3, 2020 07:09
@Stebalien
Copy link
Member

(I still need to actually review this)

@dirkmc dirkmc marked this pull request as ready for review March 9, 2020 13:43
var pm *bspm.PeerManager
// onPeerResponseTimeout is triggered when a peer fails to respond to any
// request for a long time
onPeerResponseTimeout := func(peers []peer.ID) {
Copy link
Member

Choose a reason for hiding this comment

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

You can just pass pm.OnTimeout (without the function)

if rq.active {
// The queue is in order from earliest to latest, so if we
// didn't find an expired entry we can stop iterating
if time.Since(rq.sent) < ptm.peerResponseTimeout {
Copy link
Member

Choose a reason for hiding this comment

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

Let's take the time once. Or just use the time from the timer.

@@ -413,6 +415,9 @@ func (mq *MessageQueue) sendMessage() {

mq.simulateDontHaveWithTimeout(message)

// Signal that a request was sent
mq.onRequestSent(mq.p)
Copy link
Member

Choose a reason for hiding this comment

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

Concerned that doing this after sending the request could cause us to handle this after receiving the response.

var inOrder []*request
for {
select {
case rq := <-ptm.requestSent:
Copy link
Member

Choose a reason for hiding this comment

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

Raised OOB by @dirkmc: we need a single channel to prevent reordering.

// Keep track of requests sent to a peer, and the order of requests
requestsSent := make(map[peer.ID]*request)
var inOrder []*request
for {
Copy link
Member

Choose a reason for hiding this comment

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

Raised OOB in a call: We need to handle cancels. To do that, we're probably going to have to track every request.

@dirkmc
Copy link
Contributor Author

dirkmc commented Mar 10, 2020

This approach doesn't really provide enough protection against misbehaving peers for it to be worth it. For example a peer can timeout on half the requests and still remain in the session.

Instead we plan to use the existing DONT_HAVE timeout tracking that we apply to older peers, and simply apply that to newer peers also.

Closing in favour of #284

@dirkmc dirkmc closed this Mar 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ipfs/go-bitswap] Remove unresponsive peers from Sessions
2 participants