-
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] Avoid execute prepareInitPoliciesCacheAsync if namespace is deleted #22268
[fix][broker] Avoid execute prepareInitPoliciesCacheAsync if namespace is deleted #22268
Conversation
...ker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
Outdated
Show resolved
Hide resolved
...src/test/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesServiceTest.java
Outdated
Show resolved
Hide resolved
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #22268 +/- ##
============================================
+ Coverage 73.57% 73.64% +0.07%
+ Complexity 32624 32234 -390
============================================
Files 1877 1887 +10
Lines 139502 139396 -106
Branches 15299 15287 -12
============================================
+ Hits 102638 102664 +26
+ Misses 28908 28785 -123
+ Partials 7956 7947 -9
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@dao-jun Could you set the related milestone and labels before merging? |
@nodece @poorbarcode Do you check the test codes whether it is matched with the reproduced steps ? |
oh, I didn't noticed |
The test could not pass. The reproduce steps is below:
But the fix will cause another issue in the following steps:
BTW, the new issue will also happen when the internal reader starts failing(before the current PR). See https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java#L351-L361 |
This test works fine, but |
yes, I have tested locally, it's fine. |
…e is deleted (apache#22268) (cherry picked from commit 96d77f7) (cherry picked from commit d4610a0)
…e is deleted (apache#22268) (cherry picked from commit 96d77f7) (cherry picked from commit d4610a0)
…e is deleted (apache#22268) (cherry picked from commit 96d77f7) (cherry picked from commit d4610a0)
…e is deleted (apache#22268) (cherry picked from commit 96d77f7) (cherry picked from commit d4610a0)
…e is deleted (apache#22268) (cherry picked from commit 96d77f7) (cherry picked from commit d4610a0)
Motivation
If the namespace has been deleted,
prepareInitPoliciesCacheAsync
should not be executed.More detailed description:
When the namespace is forcibly deleted, if a topic exists and the own bundle of the topic is not loaded into the memory, deleting the namespace will trigger the loading of the bundle, which will trigger the execution of
prepareInitPoliciesCacheAsync
(load topic policies). However, at this time, due to the namespace is already in a deleted state, so execution will print the following exception log.Minimal reproduce step:
1.Start a single broker node and create a tenant
test-tenant
2.Create a new namespace and a new partitioned topic.
sh bin/pulsar-admin namespaces create test-tenant/test-ns
sh bin/pulsar-admin topics create-partitioned-topic test-tenant/test-ns/test-topic -p 1
3.Delete namespace force.
sh bin/pulsar-admin namespaces delete -f test-tenant/test-ns
We will see the following log:

Modifications
Skip prepare init policies cache if the namespace has been deleted.
Documentation
doc
doc-required
doc-not-needed
doc-complete