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 parseMessageMetadata error cause by not skip broker entry metadata #10968

Merged
merged 4 commits into from Jun 18, 2021

Conversation

aloyszhang
Copy link
Contributor

@aloyszhang aloyszhang commented Jun 18, 2021

Fixes #10967

Motivation

fix parseMessageMetadata error cause by not skip broker entry metadata

Modifications

skip broker entry metadata if exist before parsing message metadata

@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

@lhotari
Copy link
Member

lhotari commented Jun 18, 2021

@aloyszhang Would it be able to add some tests that verify the behavior? A failing test is a good starting point for fixing a bug.

@lhotari
Copy link
Member

lhotari commented Jun 18, 2021

It seems that skipBrokerEntryMetadataIfExist is called separately in many locations in Pulsar code base, before calling parseMessageMetadata method. For example:

public static MessageImpl<byte[]> deserializeSkipBrokerEntryMetaData(
ByteBuf headersAndPayloadWithBrokerEntryMetadata) throws IOException {
@SuppressWarnings("unchecked")
MessageImpl<byte[]> msg = (MessageImpl<byte[]>) RECYCLER.get();
Commands.skipBrokerEntryMetadataIfExist(headersAndPayloadWithBrokerEntryMetadata);
Commands.parseMessageMetadata(headersAndPayloadWithBrokerEntryMetadata, msg.msgMetadata);
msg.payload = headersAndPayloadWithBrokerEntryMetadata;
msg.messageId = null;
msg.topic = null;
msg.cnx = null;
msg.properties = Collections.emptyMap();
msg.brokerEntryMetadata = null;
return msg;
}

Commands.skipBrokerEntryMetadataIfExist(metadataAndPayload);
MessageMetadata metadata = Commands.parseMessageMetadata(metadataAndPayload);

skipBrokerEntryMetadataIfExist(metadataAndPayload);
MessageMetadata metadata = Commands.parseMessageMetadata(metadataAndPayload);

skipBrokerEntryMetadataIfExist(metadataAndPayload);
MessageMetadata metadata = Commands.parseMessageMetadata(metadataAndPayload);

It seems that this inconsistency would have to be resolved.

@lhotari lhotari added this to the 2.9.0 milestone Jun 18, 2021
@lhotari lhotari added the type/bug The PR fixed a bug or issue reported a bug label Jun 18, 2021
@BewareMyPower
Copy link
Contributor

I agree with @lhotari, the extra call of skipBrokerEntryMetadataIfExist should be removed.

Regarding to the unit tests, I think the existed tests already cover the cases when broker entry metadata is not enabled. For the case that broker entry metadata is enabled, some tests have been added to BrokerEntryMetadataE2ETest that could also cover the case. IMO, you can only add tests to cover #10950 since this PR could solve the problem completely.

/cc @wuzhanpeng

@aloyszhang
Copy link
Contributor Author

@BewareMyPower @lhotari I'll remove the extra call of skipBrokerEntryMetadataIfExist and add some tests.

@aloyszhang
Copy link
Contributor Author

/pulsarbot run-failure-checks

@aloyszhang
Copy link
Contributor Author

@lhotari @BewareMyPower PTAL

Copy link
Member

@lhotari lhotari left a comment

Choose a reason for hiding this comment

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

LGTM

@BewareMyPower BewareMyPower merged commit 0774b5f into apache:master Jun 18, 2021
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
apache#10968)

Fixes apache#10967

### Motivation
fix parseMessageMetadata error cause by not skip broker entry metadata 

### Modifications

skip broker entry metadata if exist before parsing message metadata
codelipenghui pushed a commit that referenced this pull request Jun 25, 2021
#10968)

Fixes #10967

### Motivation
fix parseMessageMetadata error cause by not skip broker entry metadata 

### Modifications

skip broker entry metadata if exist before parsing message metadata

(cherry picked from commit 0774b5f)
@codelipenghui codelipenghui added the cherry-picked/branch-2.8 Archived: 2.8 is end of life label Jun 25, 2021
@aloyszhang aloyszhang deleted the broker-entry-metadata branch August 2, 2021 02:30
eolivelli pushed a commit to datastax/pulsar that referenced this pull request Sep 6, 2021
apache#10968)

Fixes apache#10967

### Motivation
fix parseMessageMetadata error cause by not skip broker entry metadata

### Modifications

skip broker entry metadata if exist before parsing message metadata

(cherry picked from commit 0774b5f)
BewareMyPower pushed a commit to streamnative/kop that referenced this pull request Sep 30, 2021
BewareMyPower pushed a commit to streamnative/kop that referenced this pull request Sep 30, 2021
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
apache#10968)

Fixes apache#10967

### Motivation
fix parseMessageMetadata error cause by not skip broker entry metadata 

### Modifications

skip broker entry metadata if exist before parsing message metadata
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/broker cherry-picked/branch-2.8 Archived: 2.8 is end of life release/2.8.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
4 participants