-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Cardinality violations in Client streaming RPC. #8278
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -542,6 +542,8 @@ type clientStream struct { | |
|
||
sentLast bool // sent an end stream | ||
|
||
recvMsg bool // received msg from server | ||
|
||
methodConfig *MethodConfig | ||
|
||
ctx context.Context // the application's context, wrapped by stats/tracing | ||
|
@@ -1134,11 +1136,17 @@ func (a *csAttempt) recvMsg(m any, payInfo *payloadInfo) (err error) { | |
if statusErr := a.transportStream.Status().Err(); statusErr != nil { | ||
return statusErr | ||
} | ||
if cs.desc.ClientStreams && !cs.desc.ServerStreams && !cs.recvMsg{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we leave out There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The vet checks is failing, probably because of the missing space before |
||
return status.Errorf(codes.Internal, "client streaming cardinality violation") | ||
} | ||
return io.EOF // indicates successful end of stream. | ||
} | ||
|
||
return toRPCErr(err) | ||
} | ||
if cs.desc.ClientStreams { | ||
cs.recvMsg = true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we set this boolean without the check? Otherwise we would need to document the variable in a way to make it obvious that this is set only for client streaming RPCs. Even then users may accidentally use it for other types of RPCs. |
||
} | ||
if a.trInfo != nil { | ||
a.mu.Lock() | ||
if a.trInfo.tr != nil { | ||
|
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.
nit: Boolean field names should be like questions with yes/no answers, example "didReceiveFirstMessage".