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

Adding compressor (GZIPCompressor) cause inconsistent behavior when sending message #730

Closed
VenkateshSub opened this issue Jun 24, 2016 · 4 comments

Comments

@VenkateshSub
Copy link

Hi,

When we enable compression (eg: GZIPCompressor) and send multiple messages (from server or client), the buffers seem to not be cleaned up properly causing inconsistent behavior.

stream.go
Checkout the serverStream.SendMsg and clientStream.SendMsg, both of these call encode() function with a buffer (cbuf) parameter.

rpc_util.go:
encode(c Codec, msg interface{}, cp Compressor, cbuf *bytes.Buffer) ([]byte, error) {

Inside encode function, cbuf is only used as a transient variable to hold the compressed bytes. Eventually it still goes ahead and makes a new buffer to add the headers before the data.

The problem is, when the subsequent sendMsg gets called, the cbuf sometimes may or may not be empty, causing the issue. Completely removing the cbuf and replacing it with a sync.pool makes it work.. I wanted to check here for any suggestions. Thanks for your help!

@VenkateshSub VenkateshSub changed the title Adding compressor (GZIPCompressor) cause inconsistent behavior Adding compressor (GZIPCompressor) cause inconsistent behavior when sending message Jun 24, 2016
@menghanl
Copy link
Contributor

cbuf is cleaned at https://github.com/grpc/grpc-go/blob/master/stream.go#L230

Is SendMsg() called concurrently in your program? We currently don't support concurrent writers for stream.

@hsaliak
Copy link

hsaliak commented May 17, 2017

@VenkateshSub is this still an issue, if so, could you give us some more details?

@timbunce
Copy link

We currently don't support concurrent writers for stream.

Where is this documented? (See also #682)

@dfawley
Copy link
Member

dfawley commented Jul 19, 2017

https://godoc.org/google.golang.org/grpc#Stream

This is a bit difficult to document, because the user typically works with the generated code that wraps this, and doesn't produce godocs. I hope to add some basic documentation in the next 2-3 months to cover this and other FAQs.

@dfawley dfawley closed this as completed Jul 19, 2017
@lock lock bot locked as resolved and limited conversation to collaborators Sep 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants