wuzhanpeng opened a new pull request #11310:
URL: https://github.com/apache/pulsar/pull/11310
### Motivations
When we performing pressure tests on persistent partitioned topics, we found
that the `NullPointerException` would occasionally appear, and at the same time
the producers could no longer write messages.
Some server error log
```
java.util.concurrent.ExecutionException: java.lang.NullPointerException
at
java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:357)
at
java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1895)
at
org.apache.pulsar.broker.service.persistent.PersistentTopicTest.testPersistentPartitionedTopicUnload(PersistentTopicTest.java:268)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at
org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:132)
at
org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:45)
at
org.testng.internal.InvokeMethodRunnable.call(InvokeMethodRunnable.java:73)
at
org.testng.internal.InvokeMethodRunnable.call(InvokeMethodRunnable.java:11)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException
at
org.apache.pulsar.broker.service.BrokerService.removeTopicFromCache(BrokerService.java:1729)
at
org.apache.pulsar.broker.service.BrokerService.cleanUnloadedTopicFromCache(BrokerService.java:1699)
at
org.apache.pulsar.broker.namespace.OwnedBundle.lambda$handleUnloadRequest$1(OwnedBundle.java:136)
at
java.util.concurrent.CompletableFuture.uniHandle(CompletableFuture.java:822)
at
java.util.concurrent.CompletableFuture$UniHandle.tryFire(CompletableFuture.java:797)
at
java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at
java.util.concurrent.CompletableFuture.complete(CompletableFuture.java:1962)
```
The problem is that the cleanup logic in
`org.apache.pulsar.broker.service.BrokerService#cleanUnloadedTopicFromCache`
does not check wheather the topic reference is present. This may cause an
attempt to obtain bundle map from
`org.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)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]