-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
core: change serverimpl,servercallimpl's internalclose to cancel stream #4038
Conversation
Signed-off-by: Rama <[email protected]>
Signed-off-by: Rama <[email protected]>
@@ -205,7 +205,7 @@ public String getAuthority() { | |||
* on. | |||
*/ | |||
private void internalClose(Status internalError) { | |||
stream.close(internalError, new Metadata()); | |||
stream.cancel(internalError); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This status is stored internally in gRPC, but won't actually be exposed anywhere on server-side. We should probably go ahead and log it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. which level? Is SEVERE
the correct level? I have added with WARN
. Let me know if needs to be changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
WARNING seems good. SEVERE seems a bit too much, because we were able to recover.
@@ -247,7 +247,7 @@ public void onCompleted() { | |||
.onNext(StreamingInputCallRequest.getDefaultInstance()); | |||
|
|||
assertTrue(finishLatch.await(900, TimeUnit.MILLISECONDS)); | |||
assertEquals(Status.UNKNOWN, Status.fromThrowable(throwableRef.get())); | |||
assertEquals(Status.CANCELLED.getCode(), Status.fromThrowable(throwableRef.get()).getCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right now calling serverStream.cancel()
will propagate a CANCEL HTTP/2 error to the remote. It'd probably be better if it was INTERNAL_ERROR, which will get mapped to a INTERNAL grpc status code. That way the client would get a signal that it shouldn't retry.
I think it'd be fair to map gRPC's DEADLINE_EXCEEDED and CANCELLED error codes to HTTP/2's CANCEL, and everything else map to HTTP/2's INTERNAL_ERROR. Right now we use DEADLINE_EXCEEDED for when deadline expires. That mapping could be in NettyServerHandler.cancelStream()
.
@@ -610,8 +610,7 @@ void setListener(ServerStreamListener listener) { | |||
* Like {@link ServerCall#close(Status, Metadata)}, but thread-safe for internal use. | |||
*/ | |||
private void internalClose() { | |||
// TODO(ejona86): this is not thread-safe :) | |||
stream.close(Status.UNKNOWN, new Metadata()); | |||
stream.cancel(Status.INTERNAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix doc comments if you change? edit: Please don't care.
…ncelStream Signed-off-by: Rama <[email protected]>
@ejona86 addressed the comments, PTAL and let me know if any further changes are needed. |
Signed-off-by: Rama <[email protected]>
@@ -205,7 +207,8 @@ public String getAuthority() { | |||
* on. | |||
*/ | |||
private void internalClose(Status internalError) { | |||
stream.close(internalError, new Metadata()); | |||
log.log(Level.WARNING,format("cancelling the stream with status %s",internalError.toString())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass internalError
as an argument and use MessageFormat-style syntax:
log.log(Level.WARNING, "Cancelling the stream with status {0}", new Object[] {internalError});
We mainly use String.format()
when we need to create a gRPC status description with an argument.
One small change, and then I can merge. |
…rmat Signed-off-by: Rama <[email protected]>
@ejona86 changed. PTAL. |
…ose to cancel stream (grpc#4038)" This partially reverts commit 48ca452. It leaves the changes to ServerCallImpl and test. This also partially reverts "Lint fixes" commit 3002a23 which removed unused variables which are now necessary again. This is reverted for the combined result of two issues: * Some users are testing that they get UNKNOWN when the service throws. That's not unreasonable given the behavior was well-publicised when it changed in v1.5. We should probably keep the UNKNOWN in some common cases (like the service threw immediately, before sending anything). * The client always saw CANCELLED, not INTERNAL as had been intended. This is behavior is visible in the tests and was overlooked during reveiw.
…ose to cancel stream (grpc#4038)" This partially reverts commit 48ca452. It leaves the changes to ServerCallImpl and test. This also partially reverts "Lint fixes" commit 3002a23 which removed unused variables which are now necessary again. This is reverted for the combined result of two issues: * Some users are testing that they get UNKNOWN when the service throws. That's not unreasonable given the behavior was well-publicised when it changed in v1.5. We should probably keep the UNKNOWN in some common cases (like the service threw immediately, before sending anything). * The client always saw CANCELLED, not INTERNAL as had been intended. This is behavior is visible in the tests and was overlooked during review.
…ose to cancel stream (grpc#4038)" This partially reverts commit 48ca452. It leaves the changes to ServerCallImpl and test. This also partially reverts "Lint fixes" commit 3002a23 which removed unused variables which are now necessary again. This is reverted for the combined result of two issues: * Some users are testing that they get UNKNOWN when the service throws. That's not unreasonable given the behavior was well-publicised when it changed in v1.5. We should probably keep the UNKNOWN in some common cases (like the service threw immediately, before sending anything). * The client could see CANCELLED instead of INTERNAL as had been intended. It's unclear as to why (I didn't investigate heavily). This behavior is visible in MoreInProcessTest and was overlooked during review.
…ose to cancel stream (#4038)" This partially reverts commit 48ca452. It leaves the changes to ServerCallImpl and test. This also partially reverts "Lint fixes" commit 3002a23 which removed unused variables which are now necessary again. This is reverted for the combined result of two issues: * Some users are testing that they get UNKNOWN when the service throws. That's not unreasonable given the behavior was well-publicised when it changed in v1.5. We should probably keep the UNKNOWN in some common cases (like the service threw immediately, before sending anything). * The client could see CANCELLED instead of INTERNAL as had been intended. It's unclear as to why (I didn't investigate heavily). This behavior is visible in MoreInProcessTest and was overlooked during review.
Signed-off-by: Rama [email protected]
Fixes #3819, #3746