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

cli: make the quit command more robust #14775

Merged
merged 1 commit into from
Apr 11, 2017

Conversation

andreimatei
Copy link
Contributor

Fixes #14184

The quit command send a streaming RPC and expects the connection to
drop. Except it wasn't handling the case where the connection dropped
before the client was even returning from the RPC call.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@andreimatei andreimatei force-pushed the fix-quit branch 2 times, most recently from 2345bba to 53b785e Compare April 10, 2017 23:18
@tamird
Copy link
Contributor

tamird commented Apr 10, 2017

Well I'm not sure how this fixes #14184, but lgtm otherwise.


Reviewed 2 of 2 files at r1.
Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful.


pkg/cli/start.go, line 650 at r1 (raw file):

	// and that's all that this function is interested in.
	for {
		if _, err := stream.Recv(); err != nil {

what error are you expecting here?


Comments from Reviewable

@andreimatei
Copy link
Contributor Author

I hope it fixes it because the failures I saw were the "connection is fucked" errors received by the grpc call itself (as opposed to received by stream.Recv, where we expect them).
Did you see... other failures?


Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful.


pkg/cli/start.go, line 650 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

what error are you expecting here?

I'm not expecting any errors... Other than io.EOF. But I'm ignoring all errors anyway.
The point of this code is simply to consume the stream; I'm assuming that gRPC would like me to do that.


Comments from Reviewable

@tamird
Copy link
Contributor

tamird commented Apr 10, 2017

Review status: all files reviewed at latest revision, 1 unresolved discussion, all commit checks successful.


pkg/cli/start.go, line 650 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

I'm not expecting any errors... Other than io.EOF. But I'm ignoring all errors anyway.
The point of this code is simply to consume the stream; I'm assuming that gRPC would like me to do that.

why is this loop not infinite? Does the remote hang up?


Comments from Reviewable

@a-robinson
Copy link
Contributor

:lgtm:


Reviewed 2 of 2 files at r1.
Review status: all files reviewed at latest revision, 2 unresolved discussions, all commit checks successful.


pkg/cli/start.go, line 645 at r1 (raw file):

	})
	if err != nil {
		return errors.Wrap(err, "Failed to connect to the node: error sending drain request")

Minor, but is the "error sending drain request" part of this message actually clarifying anything for anyone?


pkg/cli/start.go, line 650 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

why is this loop not infinite? Does the remote hang up?

I'm also curious about this. Shouldn't we just close the stream and return rather than receiving on it?


Comments from Reviewable

@andreimatei
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 2 unresolved discussions, all commit checks successful.


pkg/cli/start.go, line 645 at r1 (raw file):

Previously, a-robinson (Alex Robinson) wrote…

Minor, but is the "error sending drain request" part of this message actually clarifying anything for anyone?

ummm I dunno... It gives some info about the context; I'll keep it.


pkg/cli/start.go, line 650 at r1 (raw file):
The RPC server returns from the RPC handler, so at that point this guy will get either an EOF or an error.

Shouldn't we just close the stream and return rather than receiving on it?

Apparently there's no "close the stream". With a "client stream" you can close the send direction, but not the receive direction (I have no idea why there's a CloseSend()...). What you're supposed to do if you don't care about the result of a server-side streaming RPC is create a cancellable context and cancel it. But I don't think it's worth doing here.


Comments from Reviewable

@tamird
Copy link
Contributor

tamird commented Apr 11, 2017

Review status: all files reviewed at latest revision, 2 unresolved discussions, all commit checks successful.


pkg/cli/start.go, line 650 at r1 (raw file):

Previously, andreimatei (Andrei Matei) wrote…

The RPC server returns from the RPC handler, so at that point this guy will get either an EOF or an error.

Shouldn't we just close the stream and return rather than receiving on it?

Apparently there's no "close the stream". With a "client stream" you can close the send direction, but not the receive direction (I have no idea why there's a CloseSend()...). What you're supposed to do if you don't care about the result of a server-side streaming RPC is create a cancellable context and cancel it. But I don't think it's worth doing here.

We should at least log if we get a non EOF error here.


Comments from Reviewable

Fixes cockroachdb#14184

The quit command send a streaming RPC and expects the connection to
drop. Except it wasn't handling the case where the connection dropped
before the client was even returning from the RPC call.
@andreimatei
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 2 unresolved discussions, all commit checks successful.


pkg/cli/start.go, line 650 at r1 (raw file):

Previously, tamird (Tamir Duberstein) wrote…

We should at least log if we get a non EOF error here.

Done.


Comments from Reviewable

@tamird
Copy link
Contributor

tamird commented Apr 11, 2017

Reviewed 1 of 1 files at r2.
Review status: all files reviewed at latest revision, 2 unresolved discussions, some commit checks pending.


Comments from Reviewable

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.

4 participants