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

grpc-rs doesn't compress response when client sent a compressed request #534

Closed
lysu opened this issue Jun 17, 2021 · 3 comments
Closed

Comments

@lysu
Copy link

lysu commented Jun 17, 2021

tidb will use grpc to communicate with both tikv and other tidb.

when investigating an issue we found that only tidb->tidb got empty result due to grpc/grpc-go#4552

but tikv works well, after more investigation it seems tikv server doesn't give a compressed response like grpc-go does, grpc-go seems response compressed data when client seen compressed data even if it doesn't enable compress in server-side.

I'm not sure is it a problem, ptal~

@BusyJay
Copy link
Member

BusyJay commented Jun 17, 2021

Can you provide a minimal reproduce example? Server won't compress response if the compression algorithm is not supported.

@lysu
Copy link
Author

lysu commented Jun 17, 2021

yes, we could use

https://github.com/lysu/grpc-go/blob/dev-test/examples/helloworld/greeter_client/main.go

as client...

and

https://github.com/tikv/grpc-rs/blob/fd66ec789b2601cd88f015fa4a33a6b5da431c11/tests-and-examples/examples/hello_world/server.rs

as server..

and check server response by set breakpoint on google.golang.org/grpc.recvAndDecompress at rpc_util.go:703, and watch pf var:

image

if server is rust, pf will be compressionNone... but compressionMade if we use go version https://github.com/lysu/grpc-go/blob/1ddc040f5c6c061b33331a50d6d08337e4a3e964/examples/helloworld/greeter_server/main.go

I also try to .default_compression_algorithm(CompressionAlgorithms::GRPC_COMPRESS_GZIP) in rust example, but it's still compressionNone

@BusyJay
Copy link
Member

BusyJay commented Jun 17, 2021

After commenting following line, the official cpp version of compression example also doesn't compress the response:

https://github.com/grpc/grpc/blob/master/examples/cpp/compression/greeter_server.cc#L44

It seems one has to set the compression type in server side to make it work. The cookbook https://github.com/grpc/grpc/blob/master/doc/compression_cookbook.md also doesn't have a clear statement that server response will use the same compression algorithm as client. The only one clear rule I can find is from go-grpc's documentation, which is a different implementation.

https://github.com/grpc/grpc-go/blob/master/Documentation/compression.md#server-side

@lysu lysu closed this as completed Jun 22, 2021
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

No branches or pull requests

2 participants