-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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 get topic policies as null during clean cache #20763
Conversation
...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
Outdated
Show resolved
Hide resolved
...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
Outdated
Show resolved
Hide resolved
64d1f54
to
7d39b82
Compare
7d39b82
to
295ad12
Compare
@@ -3015,6 +3019,63 @@ public void testLoopCreateAndDeleteTopicPolicies() throws Exception { | |||
}); | |||
} | |||
} | |||
|
|||
@Test | |||
public void testGetTopicPoliciesWithCleanCache() |
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.
@coderzc Can you reproduce the issue with this test with the fix? I have tried it on my laptop without this fix. But can't reproduce the issue. The fix looks good, just the test can't protect the changes of this PR.
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 have rewritten the test to make it can reproduce the issue.
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.
@codelipenghui PTAL.
@@ -3015,6 +3015,7 @@ public void testLoopCreateAndDeleteTopicPolicies() 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.
can you delete the blank line?
Codecov Report
@@ Coverage Diff @@
## master #20763 +/- ##
=============================================
+ Coverage 36.80% 73.11% +36.31%
- Complexity 12073 32128 +20055
=============================================
Files 1689 1866 +177
Lines 129387 139041 +9654
Branches 14120 15294 +1174
=============================================
+ Hits 47619 101661 +54042
+ Misses 75482 29322 -46160
- Partials 6286 8058 +1772
Flags with carried forward coverage won't be shown. Click here to find out more.
|
(cherry picked from commit 3116abf)
(cherry picked from commit 3116abf)
(cherry picked from commit 3116abf)
(cherry picked from commit 3116abf)
…he (apache#20763)" This reverts commit 111c14d. (cherry picked from commit ab9384b)
…he (apache#20763)" This reverts commit 111c14d. (cherry picked from commit ab9384b)
…he (apache#20763)" This reverts commit 111c14d. (cherry picked from commit ab9384b)
Motivation
Currently, we may get topic policies as null during the clean topic policies since there is a race condition between them.
getTopicPolicies
cleanCacheAndCloseReader
the value of this namespace
policyCacheInitMap is
true
from policiesCache as
null
Modifications
Use
policyCacheInitMap.compute()
to make get topic policies init flag and clean cache mutually exclusive.Verifying this change
(Please pick either of the following options)
This change is a trivial rework / code cleanup without any test coverage.
(or)
This change is already covered by existing tests, such as (please describe tests).
(or)
This change added tests and can be verified as follows:
(example:)
Documentation
doc
doc-required
doc-not-needed
doc-complete
Matching PR in forked repository
PR in forked repository: