-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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 compression timestamps #759
Changes from 2 commits
f7ed0d9
b1f4708
425aaad
413f13f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,11 +90,29 @@ func (ps *produceSet) buildRequest() *ProduceRequest { | |
Logger.Println(err) // if this happens, it's basically our fault. | ||
panic(err) | ||
} | ||
req.AddMessage(topic, partition, &Message{ | ||
compMsg := &Message{ | ||
Codec: ps.parent.conf.Producer.Compression, | ||
Key: nil, | ||
Value: payload, | ||
}) | ||
} | ||
if ps.parent.conf.Version.IsAtLeast(V0_10_0_0) { | ||
// Compressed messages must use a protocol version | ||
// that is newer than the inner messages version. | ||
// Due to a lack of better timestamp notation copy the oldest | ||
// (earliest) timestamp to message. | ||
for _, msgBlock := range set.setToSend.Messages { | ||
msg := msgBlock.Msg | ||
if msg.Version > compMsg.Version { | ||
compMsg.Version = msg.Version | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I was thinking about better ways to accomplish this and I wonder now if the code in edit: actually this issue goes away if we provide a timestamp of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think always using v1 would be great, I don't see a reason to switch back at all. Providing a default of time.Now() sounds like a good idea, too. |
||
} | ||
if !msg.Timestamp.IsZero() && | ||
(compMsg.Timestamp.IsZero() || | ||
compMsg.Timestamp.After(msg.Timestamp)) { | ||
compMsg.Timestamp = msg.Timestamp | ||
} | ||
} | ||
} | ||
req.AddMessage(topic, partition, compMsg) | ||
} | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor nit-pick: as I understand it (and as you've implemented here) the outer version has to be at least as new as the inner version, not strictly newer.