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

rpc_util: Change error message to indicate size after decompression #4918

Merged
merged 4 commits into from Nov 11, 2021

Conversation

uds5501
Copy link
Contributor

@uds5501 uds5501 commented Nov 1, 2021

Fixes #4761

RELEASE NOTES:

  • client: clarify errors to indicate whether compressed or uncompressed messages exceeded size limits

@uds5501
Copy link
Contributor Author

uds5501 commented Nov 1, 2021

@menghanl @dfawley
I have changed the error message as required in the issue, kindly let me know if any other change is required.

rpc_util.go Outdated
@@ -570,7 +570,7 @@ func (p *parser) recvMsg(maxReceiveMessageSize int) (pf payloadFormat, msg []byt
return 0, nil, status.Errorf(codes.ResourceExhausted, "grpc: received message larger than max length allowed on current machine (%d vs. %d)", length, maxInt)
}
if int(length) > maxReceiveMessageSize {
return 0, nil, status.Errorf(codes.ResourceExhausted, "grpc: received message larger than max (%d vs. %d)", length, maxReceiveMessageSize)
return 0, nil, status.Errorf(codes.ResourceExhausted, "grpc: received message after decompression larger than max (%d vs. %d)", length, maxReceiveMessageSize)
Copy link
Member

Choose a reason for hiding this comment

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

This isn't correct. This is the raw message before decompression. recvAndDecompress calls this and decompresses this payload as a separate step.

Copy link
Member

Choose a reason for hiding this comment

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

Also note that we can't call this the "compressed" message, since we don't know whether it's compressed in the first place. pf can tell us whether it's compressed if we can't come up with a generic enough message to convey the idea properly.

Copy link
Contributor Author

@uds5501 uds5501 Nov 3, 2021

Choose a reason for hiding this comment

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

@dfawley
I have a small question, I was writing this fix after reading this comment here:

#4761 (comment)

In this, the issue creator says that he is "compressing" an 8 MB message to 4 MB and then sending it over.
Now, in our logic, since we are decompressing it, later on, is it possible that your current logic and error used are absolutely right and the message was not compressed in the first place?

If so, then this PR is irrelevant.

Copy link
Member

Choose a reason for hiding this comment

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

We check the message size twice. Here (not yet decompressed) and here after decompressing:

return nil, status.Errorf(codes.ResourceExhausted, "grpc: received message larger than max (%d vs. %d)", size, maxReceiveMessageSize)

And if a message isn't compressed, it seems like we might be checking the size twice, which we could clean up as part of this. The issue is about clarifying whether it's the compressed message or the decompressed message size was over the limit (if the message is compressed).

@zasweq zasweq added this to the 1.43 release milestone Nov 2, 2021
@uds5501
Copy link
Contributor Author

uds5501 commented Nov 5, 2021

@dfawley Thank you for the review and pointers.

I have moved up this check so that we recheck the size once decompression is completed, also I have removed the message change from the first check itself.

Ps: also, could you help me in adding labels to this PR? Mergeable bot seems to require it.

@uds5501 uds5501 requested a review from dfawley November 5, 2021 08:00
@dfawley dfawley added the Type: Documentation Documentation or examples label Nov 9, 2021
@dfawley
Copy link
Member

dfawley commented Nov 9, 2021

Just noticed the vet error: rpc_util.go:721:3: this value of size is never used (SA4006). You can remove the setting of size in the else to fix it.

@uds5501
Copy link
Contributor Author

uds5501 commented Nov 11, 2021

@dfawley Removed that, thanks for pointing out

@dfawley dfawley merged commit ea068ed into grpc:master Nov 11, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make MaxCallRecvMsgSize errors clear whether it's compressed or uncompressed
4 participants