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

client: add GRPC_GO_REQUIRE_HANDSHAKE options to control connection behavior #2464

Merged
merged 7 commits into from
Nov 26, 2018

Conversation

dfawley
Copy link
Member

@dfawley dfawley commented Nov 21, 2018

#2406

Possible settings of this environment variable:

  • "hybrid" (default; removed after the 1.17 release): do not wait for handshake before considering a connection ready, but wait before considering successful.

  • "on" (default after the 1.17 release): wait for handshake before considering a connection ready/successful.

  • "off": do not wait for handshake before considering a connection ready/successful.

This setting will be completely removed after the 1.18 release, and "on" will be the only supported behavior.

@menghanl
Copy link
Contributor

"hybrid" (default; removed after the 1.17 release): wait for handshake before considering a connection ready, but wait before considering successful.

Did you miss a "not"?

…ehavior

Possible settings of this environment variable:

- "hybrid" (default; removed after the 1.17 release): do not wait for handshake
before considering a connection ready, but wait before considering successful.

- "on" (default after the 1.17 release): wait for handshake before considering
a connection ready/successful.

- "off": do not wait for handshake before considering a connection
ready/successful.

This setting will be completely removed after the 1.18 release, and "on" will
be the only supported behavior.
@dfawley dfawley force-pushed the ready_connection_one branch from f8daa0f to 92d2ac1 Compare November 21, 2018 17:51
@dfawley
Copy link
Member Author

dfawley commented Nov 21, 2018

Did you miss a "not"?

Yes. I edited this text like 5 times, so it doesn't surprise me that I killed it at some point.

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 2 unresolved discussions (waiting on @dfawley, @jadekler, and @menghanl)


clientconn.go, line 1151 at r2 (raw file):

		prefaceMu.Lock()
		clientPrefaceWrote = true
		if serverPrefaceReceived || (!ac.dopts.waitForHandshake && ac.cc.reqHandshake == envconfig.RequireHandshakeOff) {

To make this a bit clearer, convert ac.dopts.waitForHandshake into ac.cc.reqHandshake so we don't need to check both?

// In Dial()
if dopts.waitForHandshake {
    cc.reqHandshake = envconfig.RequireHandshakeOn
}

clientconn.go, line 1169 at r2 (raw file):

				return nil
			}
		} else if ac.cc.reqHandshake == envconfig.RequireHandshakeHybrid {
if wait_for_handshake is on ...
else if hybird ...
// else (off)

The else (off) is not handled (which is fine because we don't do anything).
But it means we don't need prefaceTimer, and also we don't need the preface handler onPrefaceReceipt.

Copy link
Contributor

@menghanl menghanl left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 3 unresolved discussions (waiting on @dfawley, @jadekler, and @menghanl)


clientconn_test.go, line 150 at r2 (raw file):

}

func TestDialWaitsForServerSettings(t *testing.T) {

This is to test with WithWaitForHandshake() dial option, env variable doesn't matter, right?
Add a comment for the test?

Copy link
Member Author

@dfawley dfawley left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 5 files reviewed, 3 unresolved discussions (waiting on @menghanl and @jadekler)


clientconn.go, line 1151 at r2 (raw file):

Previously, menghanl (Menghan Li) wrote…

To make this a bit clearer, convert ac.dopts.waitForHandshake into ac.cc.reqHandshake so we don't need to check both?

// In Dial()
if dopts.waitForHandshake {
    cc.reqHandshake = envconfig.RequireHandshakeOn
}

One better: make the dopt an envconfig.RequireHandshakeSetting and share everything there.


clientconn.go, line 1169 at r2 (raw file):

Previously, menghanl (Menghan Li) wrote…
if wait_for_handshake is on ...
else if hybird ...
// else (off)

The else (off) is not handled (which is fine because we don't do anything).
But it means we don't need prefaceTimer, and also we don't need the preface handler onPrefaceReceipt.

You are correct, but I'd rather not clutter code for a minor optimization when it will be deleted in 6 more weeks.


clientconn_test.go, line 150 at r2 (raw file):

Previously, menghanl (Menghan Li) wrote…

This is to test with WithWaitForHandshake() dial option, env variable doesn't matter, right?
Add a comment for the test?

Correct. Done.

Copy link
Member

@jeanbza jeanbza left a comment

Choose a reason for hiding this comment

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

Should we deprecate WithWaitForHandshake, and/or add a note discussing the change in behavior in 1.17?

ready_connection_one

Hahahaha.

clientconn_test.go Show resolved Hide resolved
clientconn_test.go Outdated Show resolved Hide resolved
Copy link
Member Author

@dfawley dfawley 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 the review. Diffs updated.

clientconn_test.go Show resolved Hide resolved
clientconn_test.go Outdated Show resolved Hide resolved
Copy link
Member

@jeanbza jeanbza left a comment

Choose a reason for hiding this comment

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

(my small questions are resolved)

@dfawley dfawley merged commit f3eb5bc into grpc:master Nov 26, 2018
@dfawley dfawley added the Type: Feature New features or improvements in behavior label Nov 26, 2018
@dfawley dfawley added this to the 1.17 Release milestone Nov 26, 2018
@dfawley dfawley deleted the ready_connection_one branch December 6, 2018 22:08
@NeoyeElf
Copy link

I have a problem here...

I used grpc-client(v1.18.0) to send request grpc-server(v1.16.0), it turned out that request hang up (or exceed deadline when set timeout). After I have checked the change log, I found this feat: client: add GRPC_GO_REQUIRE_HANDSHAKE options to control connection behavior . With my doubt, I set the env variables "GRPC_GO_REQUIRE_HANDSHAKE=off" then it worked.

here is my questions:
Is this the only way to make it work without downgrade google.golang.org/grpc to 1.16 for my grpc-client?

Thanks...

@lock lock bot locked as resolved and limited conversation to collaborators Aug 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Type: Feature New features or improvements in behavior
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants