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

Parsing only known control batches value #1898

Merged
merged 2 commits into from
Mar 11, 2021

Conversation

mmaslankaprv
Copy link
Contributor

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

@mmaslankaprv mmaslankaprv requested a review from bai as a code owner March 10, 2021 08:45
@ghost ghost added the cla-needed label Mar 10, 2021
@bai bai requested a review from d1egoaz March 10, 2021 08:57
@bai
Copy link
Contributor

bai commented Mar 10, 2021

Thanks for your contribution! Could you please sign CLA to make this PR green? 🙏🏼

@mmaslankaprv
Copy link
Contributor Author

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 ?

@ghost ghost removed the cla-needed label Mar 10, 2021
@bai
Copy link
Contributor

bai commented Mar 10, 2021

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 🙏🏼

@@ -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
Copy link
Contributor

Choose a reason for hiding this comment

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

s/controll/control

@@ -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 {
Copy link
Contributor

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

Copy link
Contributor

@d1egoaz d1egoaz left a 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

@mmaslankaprv mmaslankaprv force-pushed the fixed-parsing-control-record-value branch from 19133fa to 942bd4c Compare March 11, 2021 12:18
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>
@mmaslankaprv
Copy link
Contributor Author

@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

I've added ControlRecord decoding tests.

@mmaslankaprv mmaslankaprv force-pushed the fixed-parsing-control-record-value branch from 942bd4c to e299b55 Compare March 11, 2021 15:21
@d1egoaz
Copy link
Contributor

d1egoaz commented Mar 11, 2021

Thanks @mmaslankaprv

@d1egoaz d1egoaz merged commit 7285d6c into IBM:master Mar 11, 2021
BenPope added a commit to BenPope/redpanda that referenced this pull request Mar 18, 2021
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>
BenPope added a commit to BenPope/redpanda that referenced this pull request Mar 18, 2021
* 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>
BenPope added a commit to BenPope/redpanda that referenced this pull request Mar 18, 2021
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>
BenPope added a commit to BenPope/redpanda that referenced this pull request Mar 18, 2021
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>
BenPope added a commit to BenPope/redpanda that referenced this pull request Mar 18, 2021
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>
joejulian pushed a commit to joejulian/redpanda that referenced this pull request Mar 10, 2023
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>
joejulian pushed a commit to joejulian/redpanda that referenced this pull request Mar 24, 2023
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>
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.

None yet

3 participants