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

Fix compressed offset bug #506

Merged
merged 8 commits into from
Dec 20, 2017
Merged

Fix compressed offset bug #506

merged 8 commits into from
Dec 20, 2017

Conversation

klippx
Copy link
Contributor

@klippx klippx commented Dec 19, 2017

Addresses #505

We are happy to change the test, since we were not sure how to set up the test scenario properly we used the "raw" approach of simply using data from our system console.

@dasch
Copy link
Contributor

dasch commented Dec 20, 2017

This should be updated to reflect #505 (comment)

# The contained messages need to have their offset corrected.
base_offset = offset - max_relative_offset
messages = message_set.messages.each_with_index.map do |message, i|
Copy link

@zmstone zmstone Dec 20, 2017

Choose a reason for hiding this comment

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

i no longer needed

@@ -28,14 +28,15 @@ def initialize(codec_name: nil, threshold: 1, instrumenter:)

# @param message_set [Protocol::MessageSet]
# @return [Protocol::MessageSet]
def compress(message_set)
def compress(message_set, offset: -1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you document that offset is just used to simulate the broker behavior?

@@ -58,10 +58,14 @@ def decompress
message_set_decoder = Decoder.from_string(data)
message_set = MessageSet.decode(message_set_decoder)

max_relative_offset = message_set.messages.last.offset
return message_set if max_relative_offset == offset
Copy link
Contributor

Choose a reason for hiding this comment

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

This definitely needs a comment explaining why that's the case :)

# of the container message. The broker will set the offset in normal operation,
# but at the client-side we set it to -1.
expect(messages.map(&:offset)).to eq [-1, 0]
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Why remove this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We moved tests to message_set_spec, and we beleived this case was already covered in the other three tests we provided. This test does has -1 as wrapper message offset, and both messages are -1, -1 as well. Hence our code will accept this as "correct from broker side" and return [-1, -1]

In the end we just thought the other test cases was more realistic. Should we add this back?

Copy link
Contributor

Choose a reason for hiding this comment

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

OK – no, that's fine, just needed to follow along.

@dasch
Copy link
Contributor

dasch commented Dec 20, 2017

Thanks for the PR! In order to ensure this doesn't break in the future, I'd love to get a few comments in the code describing the behavior.

@dasch
Copy link
Contributor

dasch commented Dec 20, 2017

Looks good! Can you verify that this works with real workloads?

# All other cases, compressed inner messages should have relative offset, with below attributes:
# - The container message should have the 'real' offset
# - The container message's offset should be the 'real' offset of the last message in the compressed batch
# - The first inner message should always have offset = 0
Copy link

Choose a reason for hiding this comment

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

sorry, I was wrong about this.
It doesn’t always start with 0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks, amended 👍🏼

@klippx
Copy link
Contributor Author

klippx commented Dec 20, 2017

@dasch We are going on christmas vacation right now, so we wont be able to work on this for about 3 weeks. So, this may take a while unfortunately i.e. creating a long feedback loop. Up to you. We are running 0.5.0 while we are on vacation which is stable for us.

Besides, even if we did run this version our consumers would use the short-circuit of not fixing the offsets since last message offset == wrapped message offset so it wont be a fair test.

@dasch
Copy link
Contributor

dasch commented Dec 20, 2017

@klippx a change of this magnitude requires some real-life testing before I dare merge it – let's wait until you're back.

@zmstone
Copy link

zmstone commented Dec 20, 2017

This pr is about the same magnitude as 42821e9
To be fair, that change was not covered by real-life testing either.
I'm not saying that tests are not important,
just that all consumers running current master code against compressed messages
are committing wrong offsets and likely skipping messages.
This change may have bug, but should not make things worse.

@piavka
Copy link

piavka commented Dec 20, 2017

totally agree with @zmstone

@dasch
Copy link
Contributor

dasch commented Dec 20, 2017

OK, seems like I have a volunteer who can test it. I'll merge and cut a pre-release.

@dasch dasch merged commit 76a97ec into zendesk:master Dec 20, 2017
@klippx klippx deleted the fix-compressed-offset-bug branch December 20, 2017 17:11
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

Successfully merging this pull request may close these issues.

4 participants