-
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
[fix][broker] Fix potential case cause retention policy not working on topic level #21041
Conversation
.thenCompose(__ -> checkReplicationAndRetryOnFailure()) | ||
.thenCompose(__ -> checkDeduplicationStatus()) | ||
.thenCompose(__ -> preCreateSubscriptionForCompactionIfNeeded()) | ||
.thenCompose(__ -> checkPersistencePolicies()) |
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.
Can this PR fix the second issue in onUpdate?
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.
yes, right
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 second issue said there are exceptions that happened when calling checkPersistencePolicies
. Can we confirm that?
And is it possible that no exceptions happening on checkPersistencePolicies but the topic is loaded before the topic policy is loaded? And the trim task also happened before the topic policy is loaded.
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 second issue said there are exceptions that happened when calling checkPersistencePolicies. Can we confirm that
The user said he didn't notice any warn log.
And is it possible that no exceptions happening on checkPersistencePolicies but the topic is loaded before the topic policy is loaded? And the trim task also happened before the topic policy is loaded.
yes, it's possible
@@ -457,4 +459,27 @@ public void testGetTopicPoliciesWithCleanCache() throws Exception { | |||
|
|||
result.join(); | |||
} | |||
|
|||
@Test | |||
public void testConfig() throws Exception { |
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 test can also get passed without this change.
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.
Updated
.thenCompose(__ -> checkReplicationAndRetryOnFailure()) | ||
.thenCompose(__ -> checkDeduplicationStatus()) | ||
.thenCompose(__ -> preCreateSubscriptionForCompactionIfNeeded()) | ||
.thenCompose(__ -> checkPersistencePolicies()) |
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 second issue said there are exceptions that happened when calling checkPersistencePolicies
. Can we confirm that?
And is it possible that no exceptions happening on checkPersistencePolicies but the topic is loaded before the topic policy is loaded? And the trim task also happened before the topic policy is loaded.
Codecov Report
@@ Coverage Diff @@
## master #21041 +/- ##
============================================
+ Coverage 72.67% 73.14% +0.47%
+ Complexity 32268 32186 -82
============================================
Files 1863 1875 +12
Lines 139397 139587 +190
Branches 15336 15349 +13
============================================
+ Hits 101308 102103 +795
+ Misses 30032 29414 -618
- Partials 8057 8070 +13
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Fixes #20968
Motivation
As described in 20968, even if the retention policy is set at the topic level, the ledger is still deleted. See the above log.
For
onUpdate
, there are two issues:pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentTopic.java
Lines 3493 to 3522 in ee91edc
Policies updated successfully
in methodcheckReplicationAndRetryOnFailure
. it confuses users.reader
read the policies andcheckPersistencePolicies
throw exception, then the retention policy will not apply to ManagedLedger config. So trim ledger will still use previous polices. And here will cause the above issue.Motivation
Policies updated successfully
in the end.thenCompose
to call async method.Documentation
doc
doc-required
doc-not-needed
doc-complete