-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[PIP 70][Issue 8617] Introduce lightweight broker entry metadata #8618
Conversation
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
@BewareMyPower Would you please also take a look? |
@jiazhai Ok |
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.
I think we should add a method isRawMetadataEnable()
to ManagedLedgerConfig
like:
public boolean isRawMetadataEnable() {
return isBrokerTimestampForMessageEnable();
}
Then if we want to support more features like message sequence id, we'll only need to change this method to return isConfig1() || isConfig2() || ...
. And other occurrences like OpAndEntry#initiate()
need no changes.
@BewareMyPower Would you give some deatils about what the method |
See pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/ManagedLedgerImpl.java Lines 1360 to 1362 in 0c71eb6
and pulsar/managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java Lines 112 to 114 in 0c71eb6
These two code blocks both check if (config.isBrokerTimestampForMessageEnable() || config.isMessageSequenceIdEnable()) Right? So we should wrap the check into a single method, like: public boolean isRawMetadataEnable() {
return isBrokerTimestampForMessageEnable() /* || isMessageSequenceIdEnable() or more checks */;
} |
@BewareMyPower |
/pulsarbot run-failure-checks |
@BewareMyPower I applied your comment, PTAL. |
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.
LGTM
/pulsarbot run-failure-checks |
4 similar comments
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
@aloyszhang Thanks for the great work. Would you please help add backward compact test, there was already some tests, e.g. |
@jiazhai I will hanlde backward compact test soon. |
/pulsarbot run-failure-checks |
1 similar comment
/pulsarbot run-failure-checks |
/pulsarbot run-failure-checks |
@@ -865,6 +866,11 @@ | |||
"please enable the system topic first.") | |||
private boolean topicLevelPoliciesEnabled = false; | |||
|
|||
@FieldContext( | |||
category = CATEGORY_SERVER, | |||
doc = "List of interceptors for broker metadata.") |
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.
doc = "List of interceptors for broker metadata.") | |
doc = "List of interceptors for entry metadata.") |
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.
will fix this.
|
||
ByteBuf duplicateBuffer = data.retainedDuplicate(); | ||
if (ml.getConfig().isBrokerEntryMetaEnabled()) { | ||
duplicateBuffer = Commands.addBrokerEntryMetadata(duplicateBuffer, |
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.
I am still not convinced why do we need to this here. ManagedLedger only handles serialized entry. The entry metadata should be appended at the broker level. I think the right place to add this logic should be done in https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java#L342.
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.
As we described in PIP-70, this feature can support continous sequenceId for Pulsar entry in the future, so, I think do these operations here is in favour of the future features. For this broker-timestamp feature only, move this logic as you suggested is a good choice. But for further extension, maybe do this logic by ManagedLedger is better. What's your opinion about this?
try { | ||
msg = MessageImpl.deserialize(entry.getDataBuffer()); | ||
return msg.isExpired(messageTTLInSeconds); | ||
pair = MessageImpl.deserializeWithBrokerEntryMetaData(entry.getDataBuffer()); |
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.
We should expose the broker metadata in the Message. So this would avoid using Pair
and a lot of if-else
logic.
We can improve msg.isExpired
logic. If entry metadata is present, use broker timestamp; otherwise use client timestamp.
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.
Thanks for your suggestion. I'll optimize the implement as follow steps:
- expose the entry metadata to MessageImpl
- if entry metadata exist, skip the deserialization of MessageMetadata
- if not exist, deserialization the MessageMetadata
/pulsarbot run-failure-checks |
…f comparation condition
/pulsarbot run-failure-checks |
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.
@aloyszhang the change looks great now! I left a couple of comments. Once you address them, I think this change is ready to merge.
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/ManagedLedgerConfig.java
Outdated
Show resolved
Hide resolved
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/OpAddEntry.java
Outdated
Show resolved
Hide resolved
...rc/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java
Outdated
Show resolved
Hide resolved
...roker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageFinder.java
Outdated
Show resolved
Hide resolved
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Show resolved
Hide resolved
...c/main/java/org/apache/pulsar/common/intercept/AppendBrokerTimestampMetadataInterceptor.java
Outdated
Show resolved
Hide resolved
pulsar-common/src/main/java/org/apache/pulsar/common/intercept/BrokerEntryMetadataUtils.java
Outdated
Show resolved
Hide resolved
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
Show resolved
Hide resolved
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
Show resolved
Hide resolved
@aloyszhang great job! |
@aloyszhang thanks for your great work. Shall the changes be documented in the user guide? If so, could you please help add the docs accordingly? Then you can ping me to review, thanks |
Fixes #8617
Motivation
Introduce lightweight raw Message metadata, details can be found PIP-70
Modifications
Verifying this change
Does this pull request potentially affect one of the following parts:
If
yes
was chosen, please highlight the changes