Add support for KIP-110 ZSTD compression - #2053
Conversation
305e898 to
7efbdfe
Compare
Magnus Edenhill (edenhill)
left a comment
There was a problem hiding this comment.
Wow, that was quick, the AK PR was merged two days ago!
This looks great, just needs a couple of minor cosmetic changes.
There was a problem hiding this comment.
should be a break; here, right?
There was a problem hiding this comment.
I can't find the source now, and I don't really remember why, but it is supposedly better to multiply by 1.75 than 2 when increasing buffers.
https://github.com/edenhill/librdkafka/blob/master/src/rdkafka_lz4.c#L268
There was a problem hiding this comment.
Add this: rd_atomic64_add(&rkb->rkb_c.zbuf_grow, 1);
There was a problem hiding this comment.
Updated
There was a problem hiding this comment.
variable definitions need to go at the top of the scope to be compatible with older non C99 compilers (MSVC).
There was a problem hiding this comment.
I updated it but it doesn't compile with c89 (no inline etc.), is this is just for MSVC compatibility?
There was a problem hiding this comment.
Yeah, at least that's the most common weird old compiler we come across frequently, and it is stuck somewhere between c89 and c99 :)
There was a problem hiding this comment.
variable definititions need to get at the top of the scope.
err shadows the top-level rd_kafka_resp_err_t err, better call this one zerr
There was a problem hiding this comment.
Better to error out here instead of crashing since the input data is from an external source.
There was a problem hiding this comment.
dito, rename to rdkafka_zstd.h, add copyright, add trailing >
There was a problem hiding this comment.
This file is automatically generated but seems to be missing the zstd stuff; make sure you build the source with make at least once to let auto-generation kick in.
There was a problem hiding this comment.
Since we're not including the zstd source we shouldn't include this license.
|
This will go in v1.0.0, which is currently the |
7efbdfe to
a9965a0
Compare
|
Yeah, we've been using zstd in Kafka for a while at Cloudflare, but it only currently "works" with Sarama, so I can't move without it. |
Move to what? :) v1.0.0 is scheduled for release within a month. |
a9965a0 to
8f08520
Compare
I wrote the Kafka table engine for ClickHouse using librdkafka, but can't use it with most topics without zstd. The librdkafka is embedded as a submodule there, so I don't have to wait for the release tag before testing it. |
|
Rebased to |
|
Thanks for reviewing! 🙌 |
8f08520 to
55c14d8
Compare
55c14d8 to
63b2bba
Compare
63b2bba to
2b21c18
Compare
|
Marek Vavruša (@vavrusa) did you get it to work in your case? We upgraded to confluent kafka 5.1.0 / 2.1.0 and set the broker default compression to ZSTD. %7|1546470506.414|APIVERSION|rdkafka#consumer-1| [thrd:sasl_plaintext://xxx/bootstrap]: sasl_plaintext://xxx/bootstrap: Feature ZSTD: Produce (7..7) supported by broker 76 is the error introduced with KIP-110: UNSUPPORTED_COMPRESSION_TYPE. Maybe we need to bump the v4 fetch version somehow as per "Zstd will only be allowed for the bumped fetch API ".? or am i missing something? version: |
|
Yes, it's been working for some time. Maybe the negotiation isn't working properly for your case? I don't know that much about Kafka itself to help you, sorry! |
|
thanks for confirming! |
|
seems fetch api v10 support was missing, by adding the the fetch protocol support for v10 i got it to work. i can clean up and submit a PR. |
This was introduced recently in https://cwiki.apache.org/confluence/display/KAFKA/KIP-110%3A+Add+Codec+for+ZStandard+Compression
And merged in apache/kafka#2267
I'm going to need some help figuring out how to test this. I think I added the prerequisites right - Fetch APIv10 and Produce APIv7.