-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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
client: Implement gRFC A6: configurable client-side retry support #2111
Conversation
Still looking at main retry logic in Reviewed 6 of 10 files at r1, 1 of 2 files at r2. clientconn.go, line 445 at r2 (raw file):
How about moving this to an environment variable instead? clientconn.go, line 1054 at r2 (raw file):
There are things similar to this done in Move those to this function, too? Or add clientconn.go, line 1633 at r2 (raw file):
Make a util struct for service_config.go, line 100 at r2 (raw file):
unexport this field. The only reason to export fields in this struct is to use service_config.go, line 106 at r2 (raw file):
This type doesn't need to be exported, either. Unless we want to provide another way to config retry other than service config. stream.go, line 433 at r2 (raw file):
Not sure if this is what the TODO is talking about. This variable is not used until line 463. Move this down after the stream.go, line 439 at r2 (raw file):
This is inaccurate if stream.go, line 468 at r2 (raw file):
To avoid the for loop, how about comparing The latter value can be calculated every time service config gets updated. Comments from Reviewable |
515f892
to
9bd5580
Compare
Review status: 7 of 10 files reviewed, 8 unresolved discussions (waiting on @menghanl) clientconn.go, line 445 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
Done. clientconn.go, line 1054 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
Deleted setSC after unexporting retry configuration fields from service config structs. clientconn.go, line 1633 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
Done. service_config.go, line 100 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
Done. service_config.go, line 106 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
Done. stream.go, line 433 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
I meant to write "not check pushback" instead. It is important to check the server pushback value before calling stream.go, line 439 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
If e != nil, that means a non-numeric response was provided, which the spec says is a valid way for the server to indicate retry should not be performed. stream.go, line 468 at r2 (raw file): Previously, menghanl (Menghan Li) wrote…
I removed the loop and replaced it by math.Pow(), but left out the optimization that avoids the need to call Pow() when we've hit the max backoff, since it should be quite rare and a minor win. Comments from Reviewable |
974b67e
to
e06ec2e
Compare
This should be ready to review again, thanks! |
991340f
to
3ce0654
Compare
Reviewed 5 of 7 files at r3, 1 of 3 files at r4, 1 of 2 files at r5, 7 of 9 files at r7, 1 of 1 files at r8, 1 of 1 files at r9. stream.go, line 329 at r9 (raw file):
Delete this struct. stream.go, line 339 at r9 (raw file):
stream.go, line 427 at r9 (raw file):
This comment is inappropriate. The wait happens in the stream.go, line 444 at r9 (raw file):
stream.go, line 581 at r9 (raw file):
Could Comments from Reviewable |
Refactor "newAttempt" so the part that gets the transport is done inside withRetry.
Review status: 14 of 16 files reviewed, 5 unresolved discussions (waiting on @menghanl and @dfawley) stream.go, line 329 at r9 (raw file): Previously, menghanl (Menghan Li) wrote…
Done. stream.go, line 339 at r9 (raw file): Previously, menghanl (Menghan Li) wrote…
This actually was necessary, because I wasn't calling stream.go, line 427 at r9 (raw file): Previously, menghanl (Menghan Li) wrote…
Done. stream.go, line 444 at r9 (raw file): Previously, menghanl (Menghan Li) wrote…
I know, but names are hard. stream.go, line 581 at r9 (raw file): Previously, menghanl (Menghan Li) wrote…
Yes, if the latest Comments from Reviewable |
Reviewed 6 of 8 files at r10. stream.go, line 266 at r10 (raw file):
Move statsHandler and traceInfo as parameters for stream.go, line 560 at r10 (raw file):
Should this return the previous received trailer? Comments from Reviewable |
Review status: 12 of 15 files reviewed, 2 unresolved discussions (waiting on @menghanl) stream.go, line 266 at r10 (raw file): Previously, menghanl (Menghan Li) wrote…
Done. stream.go, line 560 at r10 (raw file): Previously, menghanl (Menghan Li) wrote…
No...but I added a commitAttempt here since it will prevent races when users don't use the API correctly. And updated the comment. Comments from Reviewable |
Reviewed 1 of 7 files at r3, 1 of 8 files at r10, 1 of 1 files at r11. Comments from Reviewable |
😌 |
@dfawley I'm having a hard time understanding how this is implemented and supposed to be used. Setting the env variable will turn retry support on? Or does that only work when using a Service Config which is also not documented anywhere? I love gRPC but the docs stop right after the basic tutorial. 🙈 (as a sidenote: we've been using gRPC in production for over two years now so I'm not a first-time user and have read the source to some degree; the stab at the docs also isn't meant to be condescending) Any pointers would be appreciated. |
Yes, you will need to do both (set environment and enable in service config). Service configs are documented generally here, and in Go are set via the resolver (by calling ClientConn.NewServiceConfig). Our default DNS resolver will provide a service config if one exists in your TXT records (more info in the SC-in-DNS gRFC). Note that for backward compatibility reasons, the DNS resolver is not the default resolver in grpc-go, so you need to use
It's totally fair. We know our documentation is not ideal. Any specific suggestions you have about places where we can improve them and how to do so (e.g. what's better: godoc or our repo's Documentation directory or grpc.io) would be appreciated. |
This change is