-
Notifications
You must be signed in to change notification settings - Fork 627
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Wrong offset in a message on gzipped topic using simple Consumer/CosumerStream #1225
Comments
Wow, that was fast! Thank you! |
@hyperlink I'm not sure your fix is correct at all. I implemented it that way because the offset is relative within the compressed message according to the protcol. See: https://cwiki.apache.org/confluence/display/KAFKA/KIP-31+-+Move+to+relative+offsets+in+compressed+message+sets Pretty sure this 'fix' just caused even more problems. Should instead figure out why the reporters offsets were not already coming back relative. |
I will do some more testing. Maybe this has to do with the message format version setting. |
@hyperlink I think I see the issue here, you should revert that commit ASAP! The difference here is the reporter is using a compressed topic when I was testing with compressed messages within an uncompressed topic. because the entire topic is compressed, the flag appears to be getting set as compressed, yet since EVERYTHING is compressed, the message itself is not using relative offsets because it was committed as a single message. I think the fix would be if first message in the recursive decode is NOT 0, set base to 0. |
Or if you can identify correctly if its a wrapper message or not. I think theres 3 message formats: |
I have failed to reproduce the issue @aikar . Here's the branch I created in it I've added a test that sends compressed messages on an uncompressed topic. I updated the test to use a larger payload and verify the offsets (a symptom the reporter had was offset was skipped). I have tested against 2.1 kafka. |
@hyperlink your test is only covering gzip compressed topics. the issue is you just reverted a key fix in #1072 for handling compressed MESSAGES. You need to test the following scenarios: |
my initial test sent a batch of messages to be compressed in one request and it passes. I can add a more comprehensive test to verify. |
@hyperlink b9395ed#diff-3b0ab5649e17ef136651e7bbcedddb6aR150 It only uses a gzipped topic. Need to test with a non gzipped topic. The kafka protocol docs clearly document that offsets will be relative. It just seems there is some different behavior for already gzipped topics though. I think the proper fix is to revert your change, then here: Do a message count, and if we are the FIRST message in this message set, and our offset is NOT 0, then change base to 0 and assume we are using exact offsets |
The similar test right below that one creates a non gzipped topic and it passes. How did compressed offsets work before relative offsets were added? |
@hyperlink the server had to decompress and manipulate the message, then recompress it, see the KIP link above, but to quote:
|
@aikar I read more of the documentation you linked and it mentions that relative offsets for compressed messages only applies when the So far I have only observed I don't know how to trigger a higher magicByte. Maybe increase version of our fetch requests? I have tested |
@hyperlink b9395ed#diff-66813b7e60ac69d8b3b1abdcd27c72fdR15 you are only sending 1 message per .send() request. This is expected that 1 message per .send() will be 1 offset per. It's when you send multiple messages in a request like {topic, messages: [message1, message2, message3]} that the issue will be encountered. |
Actually I guess the better fix is simply: That one line change (after reverting your commit) should resolve the issue. |
actually no, because base might be 4 and the compressed payload has 20 messages in it, blarg. using base according to magic byte is the best I guess? |
I initially had my test send all messages in a batch and it passed after several runs. I am curious to know how the broker decides what magicByte value to use in these responses. |
https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol#AGuideToTheKafkaProtocol-Messagesets |
I have tried with both the included console producer and kafkacat and still magicByte 0. |
I'm really not sure what was different in my environment then. I very clearly saw relative offsets as they caused absolute devastation to us resetting a partition that was offset 100k back to 0, resetting the entire partition :/ |
note, that risk is now back in this library in its current state. We may not be able to identify the triggering factor in how relative offsets get triggered, but we know it can happen. i strongly suggest reverting that commit and apply some of the fix ideas I've said above. checking if first message offset is 0 or not and switching back to absolute for entire set if its not seems like a reasonable approach. |
Bug Report
When I use simple Consumer on gzipped topic I get wrong offsets in messages, the offsets are about twice as big as they should be. After the last message I get the
offsetOutOfRange
error. Same setup works fine on a non-compressed topic.Is there any way to overcome or fast-patch the issue? We need simple Consumer to make each application node consume its own partition (there's only one partition in the code I provided here, but we use 3 partitions in production).
Update: tried the same setup with
ConsumerStream
- same issue only withoutoffsetOutOfRange
errorEnvironment
For specific cases also provide
Include Sample Code to reproduce behavior
Client code
Set up and run code
Include output with Debug turned on
Thanks for the lib anyway!
The text was updated successfully, but these errors were encountered: