-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix][broker] Fix messages could not expire due to incorrect client clock #21835
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
Conversation
[fix][test]Fix resource not close after method
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #21835 +/- ##
============================================
+ Coverage 73.57% 74.54% +0.96%
- Complexity 32624 34145 +1521
============================================
Files 1877 1920 +43
Lines 139502 144467 +4965
Branches 15299 15806 +507
============================================
+ Hits 102638 107690 +5052
+ Misses 28908 28519 -389
- Partials 7956 8258 +302
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
Please also fix another issue with the reuse of the brokerEntryMetadata.
Replace BrokerEntryMetadata brokerEntryMetadata = BROKER_ENTRY_METADATA.get(); with BrokerEntryMetadata brokerEntryMetadata = BROKER_ENTRY_METADATA.get().clear(); (append .clear()) to ensure that the brokerTimestamp doesn't get reused from the previous time the instance was used. Otherwise the timestamp would never get updated.
|
Please also update the comment in pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java Lines 1602 to 1615 in 92e0e47
|
pulsar-common/src/main/java/org/apache/pulsar/common/protocol/Commands.java
Outdated
Show resolved
Hide resolved
| if (!brokerEntryMetadata.hasBrokerTimestamp()) { | ||
| brokerEntryMetadata.setBrokerTimestamp(System.currentTimeMillis()); | ||
| } |
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.
The broker timestamp will be set in line:1702 if the AppendBrokerTimestampMetadataInterceptor is enabled. Is this PR wants to set the broker timestamp without AppendBrokerTimestampMetadataInterceptor enabled?
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.
Unless we can ensure that the AppendBrokerTimestampMetadataInterceptor cannot be disabled, this bug may always occur
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.
Ok, I think we can either make the AppendBrokerTimestampMetadataInterceptor enabled by default or remove the AppendBrokerTimestampMetadataInterceptor to always apply the broker timestamp.
Without this change, the broker timestamp will be enabled without AppendBrokerTimestampMetadataInterceptor. Essentially, we delete the functionality of the AppendBrokerTimestampMetadataInterceptor.
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 opened a discuss in dev thread https://lists.apache.org/thread/0vtjt436xvlg0fr4ogchkjdvjcp56mvz
|
As #21940 is merged, close this PR |
Fixes #21347
Motivation
When the client machine's clock is incorrect (eg: set to 1 year later) and the Broker does not set the AppendBrokerTimestampMetadataInterceptor, the Ledger will not be cleaned up.
Because if the Broker's timestamp is not set, the expiration check will be based on the client's publish time.
Modifications
Always set the Broker's timestamp
Verifying this change
Documentation
doc-not-neededMatching PR in forked repository
PR in forked repository: 315157973#12