-
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 npe when unloading persistent partitioned topic #11310
Fix npe when unloading persistent partitioned topic #11310
Conversation
Could you help review these changes ? @codelipenghui @rdhabalia @hangc0276 |
/pulsarbot run-failure-checks |
Co-authored-by: wuzhanpeng <wuzhanpeng@bigo.sg>
@@ -1682,7 +1682,8 @@ public boolean isTopicNsOwnedByBroker(TopicName topicName) { | |||
public void cleanUnloadedTopicFromCache(NamespaceBundle serviceUnit) { | |||
for (String topic : topics.keys()) { | |||
TopicName topicName = TopicName.get(topic); | |||
if (serviceUnit.includes(topicName)) { | |||
if (getTopicReference(topic).isPresent() && serviceUnit.includes(topicName)) { |
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.
it's better to swap the position of getTopicReference(topic).isPresent()
and serviceUnit.includes(topicName)
to avoid too many calls of getTopicReference(topic).isPresent()
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.
this comment was not addressed
…oned topic in branch-2.7.
…oned topic in branch-2.7.
…opic in branch-2.7. (#11386)
@wuzhanpeng I meeted this issue too. Could you please tell me, in what situation, will the topic can be this situation? |
Co-authored-by: wuzhanpeng <wuzhanpeng@bigo.sg> (cherry picked from commit a73dc61)
Co-authored-by: wuzhanpeng <wuzhanpeng@bigo.sg>
Motivations
When we performed pressure tests on persistent partitioned topics, we found that the
NullPointerException
would occasionally appear when executing unload bundles operations, and at the same time the producers could no longer write messages.Some server error log
The problem is that the cleanup logic in
org.apache.pulsar.broker.service.BrokerService#cleanUnloadedTopicFromCache
does not check wheather the topic reference is present when unloading bundles. This may cause an attempt to obtain bundle map which does not exist fromorg.apache.pulsar.broker.service.BrokerService#multiLayerTopicsMap
during cache cleanup.Modifications
Added more safety checks to fix this issue.
Documentation
Does this pull request introduce a new feature? (no)