-
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
Parsing only known control batches value #1898
Parsing only known control batches value #1898
Conversation
Thanks for your contribution! Could you please sign CLA to make this PR green? 🙏🏼 |
I did sign the CLA, when I try to do it again it says "user with current Github name already signed the CLA". Is there anything I should do to trigger the CLA check again ? |
Oops, hiccup on our side, my apologies. I'll let Diego review this PR 🙏🏼 |
control_record.go
Outdated
@@ -55,6 +45,18 @@ func (cr *ControlRecord) decode(key, value packetDecoder) error { | |||
// UNKNOWN is used to indicate a control type which the client is not aware of and should be ignored | |||
cr.Type = ControlRecordUnknown | |||
} | |||
// we want to parse value only if we are decoding controll record of known type |
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.
s/controll/control
control_record.go
Outdated
@@ -55,6 +45,18 @@ func (cr *ControlRecord) decode(key, value packetDecoder) error { | |||
// UNKNOWN is used to indicate a control type which the client is not aware of and should be ignored | |||
cr.Type = ControlRecordUnknown | |||
} | |||
// we want to parse value only if we are decoding controll record of known type | |||
if cr.Type == ControlRecordAbort || cr.Type == ControlRecordCommit { |
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.
what about:
if cr.Type != ControlRecordUnknown
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.
@mmaslankaprv thanks for the contribution.
It looks like we're missing a/some tests in order to check for this issue.
Would be possible to add some test? I'd expect a test to fail before your change, after your change the test should pass and should be part of our continuous test
19133fa
to
942bd4c
Compare
Kafka documentation defines control batches as a single record batches containing data that shouldn't be passed to applications. The record contained inside the control batch consist of a key with well defined format and a value which format is defined by the control batch type. Control batch key format: ``` ControlRecordKey => version type version => INT16 type => INT16 ``` Fixed control batch parsing logic by first parsing the key to check if control batch is of known type and only then parsing corresponding record value. Signed-off-by: Michal Maslanka <michal@vectorized.io>
Added test validating if we correctly decode Kafka control records. Signed-off-by: Michal Maslanka <michal@vectorized.io>
I've added |
942bd4c
to
e299b55
Compare
Thanks @mmaslankaprv |
Update Sarama to include: IBM/sarama#1898 "Parsing only known control batches value" `rpk topic consume` now uses fetch v11. Related PR: redpanda-data#890 "k/server: Support serialisation for fetch v11 (RackId)" Signed-off-by: Ben Pope <ben@vectorized.io>
* Update Sarama to include: IBM/sarama#1898 * Update mocks `rpk topic consume` now uses fetch v11. Related PR: redpanda-data#890 "k/server: Support serialisation for fetch v11 (RackId)" Signed-off-by: Ben Pope <ben@vectorized.io>
Fix `rpk topic consume` * Update Sarama to include: IBM/sarama#1898 * Update mocks `rpk topic consume` now uses fetch v11 implemented in: redpanda-data#890 Signed-off-by: Ben Pope <ben@vectorized.io>
Fix `rpk topic consume` * Update Sarama to include: IBM/sarama#1898 * Update mocks `rpk topic consume` now uses fetch v11 implemented in: redpanda-data#890 Signed-off-by: Ben Pope <ben@vectorized.io>
Fix `rpk topic consume` * Update Sarama to include: IBM/sarama#1898 * Update mocks `rpk topic consume` now uses fetch v11 implemented in: redpanda-data#890 Signed-off-by: Ben Pope <ben@vectorized.io>
Fix `rpk topic consume` * Update Sarama to include: IBM/sarama#1898 * Update mocks `rpk topic consume` now uses fetch v11 implemented in: redpanda-data#890 Signed-off-by: Ben Pope <ben@vectorized.io>
Fix `rpk topic consume` * Update Sarama to include: IBM/sarama#1898 * Update mocks `rpk topic consume` now uses fetch v11 implemented in: redpanda-data#890 Signed-off-by: Ben Pope <ben@vectorized.io>
Kafka documentation defines control batches as a single record batches
containing data that shouldn't be passed to applications. The record
contained inside the control batch consist of a key with well defined
format and a value which format is defined by the control batch type.
Control batch key format:
Fixed control batch parsing logic by first parsing the key to check if
control batch is of known type and only then parsing corresponding
record value.
Signed-off-by: Michal Maslanka michal@vectorized.io