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

Set peer before sending request #1423

Merged
merged 4 commits into from
Aug 7, 2017

Conversation

jack0
Copy link
Contributor

@jack0 jack0 commented Aug 4, 2017

If a connection to the server exists but a request errors out due to context canceled or deadline exceeded, the peer information is not set. We can move setting the peer out of the recvResponse and before the sendRequest to get peer information for some failed RPCs. This addresses #1417

@MakMukhi @therc

@markdroth
Copy link
Member

It's worth noting that this may impact the retry code that @dfawley is working on (and I'm running into a similar problem in C-core). The peer that we are talking to when we send the first message may not be the one that ultimately successfully handles the request, so if we set the peer when we send the first message and then retry on a different backend later, the peer information we originally set may be incorrect. We probably need to discuss the right semantics for returning peer information in the context of retries (and the hedging case is even more unclear, since we may be talking to multiple backends simultaneously).

@therc
Copy link
Contributor

therc commented Aug 4, 2017

Retries are the kind of scenario I had in mind when I said in the original issue that maybe the peer could be set twice. And yeah, hedging is even trickier. Personally, I'd be OK if initially gRPC just tracked the last peer that succeeded/failed.
Our use case: we're trying to debug an issue with canceled contexts that does not manifest itself in a more controlled environment.

@dfawley
Copy link
Member

dfawley commented Aug 4, 2017

@markdroth interesting, thanks for calling this to my attention. I think this change is OK for us as long as nobody accesses the peer while the RPC is happening. Our API is synchronous, so this would be unexpected. For retries, it would end up being set to the last attempt, which is presumably what we want. For hedging, we will have to move things around a bit, but this won't make things much worse than they already are in that regard.

Copy link
Contributor

@MakMukhi MakMukhi left a comment

Choose a reason for hiding this comment

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

Looks good, just a small comment.

}
break
}
time.Sleep(10 * time.Millisecond)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the sleep needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's not needed, I'll remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I remembered why you need it, you need to give it sufficient time to reach the block of code that sets the peer.

Copy link
Contributor

Choose a reason for hiding this comment

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

How about we relied on something else to cause the RPC to fail, like may be trying to send a message size bigger than the max allowed message size?
This call option can be used to set a max message size allowed for a call. And the test can then deliberately try and send a message bigger than what you set.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've made the requested change, thanks!

Copy link
Contributor

@MakMukhi MakMukhi left a comment

Choose a reason for hiding this comment

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

Looks good thanks :)

@dfawley dfawley merged commit 059280c into grpc:master Aug 7, 2017
@jack0 jack0 deleted the set-peer-before-sendrequest branch August 7, 2017 18:07
menghanl pushed a commit that referenced this pull request Aug 14, 2017
@dfawley dfawley modified the milestone: 1.6 Release Aug 28, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants