Skip to content

fix parseMessageMetadata error cause by not skip broker entry metadata - #10968

Merged
BewareMyPower merged 4 commits into
apache:masterfrom
aloyszhang:broker-entry-metadata
Jun 18, 2021
Merged

BewareMyPower merged 4 commits into
apache:masterfrom
aloyszhang:broker-entry-metadata

Conversation

@aloyszhang

@aloyszhang aloyszhang commented Jun 18, 2021 •

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@lhotari

lhotari commented Jun 18, 2021

Copy link
Copy Markdown
Member

@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

lhotari commented Jun 18, 2021 •

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
Contributor Author

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

@aloyszhang

Copy link
Copy Markdown
Contributor Author

/pulsarbot run-failure-checks

@aloyszhang

Copy link
Copy Markdown
Contributor Author

@lhotari @BewareMyPower PTAL

@lhotari lhotari left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@aloyszhang
aloyszhang requested a review from BewareMyPower June 18, 2021 13:56
@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

Development

Successfully merging this pull request may close these issues.

parseMessageMetadata error when broker entry metadata enable Failed to execute Consumer#getLastMessageId when setting brokerEntryMetadataInterceptors

4 participants