Skip to content

Conversation

@mattisonchao
Copy link
Member

@mattisonchao mattisonchao commented Feb 15, 2022

Cherry pick from PR: #12773

Motivation

Sometimes, we may get TopicPoliciesCacheNotInitException with below stack trace:

15:45:47.020 [pulsar-web-41-3] INFO  org.eclipse.jetty.server.RequestLog - 10.0.0.42 - - [10/Nov/2021:15:45:47 +0000] "GET /status.html HTTP/1.1" 200 2 "-" "kube-probe/1.19+" 1
15:45:51.221 [pulsar-2-15] ERROR org.apache.pulsar.broker.admin.impl.PersistentTopicsBase - [null] Failed to perform getRetention on topic persistent://public/default/UpdateNodeCharts
java.lang.RuntimeException: org.apache.pulsar.broker.service.BrokerServiceException$TopicPoliciesCacheNotInitException: Topic policies cache have not init.
	at org.apache.pulsar.broker.service.TopicPoliciesService.lambda$getTopicPoliciesAsyncWithRetry$0(TopicPoliciesService.java:84) ~[io.streamnative-pulsar-broker-2.8.1.21.jar:2.8.1.21]
	at org.apache.pulsar.client.util.RetryUtil.executeWithRetry(RetryUtil.java:50) ~[io.streamnative-pulsar-client-original-2.8.1.21.jar:2.8.1.21]
	at org.apache.pulsar.client.util.RetryUtil.lambda$executeWithRetry$1(RetryUtil.java:63) ~[io.streamnative-pulsar-client-original-2.8.1.21.jar:2.8.1.21]
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) [?:?]
	at java.util.concurrent.FutureTask.run(FutureTask.java:264) [?:?]
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) [?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) [?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) [?:?]
	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) [io.netty-netty-common-4.1.68.Final.jar:4.1.68.Final]
	at java.lang.Thread.run(Thread.java:829) [?:?]

This is because when reader.readNextAsync() throws exceptions, the msg will be null which will throw NPE without any catch block.

Modification

  • Close reader when reader.readNextAsync() throw exceptions.
  • Remove reducant field policyCacheInitMap . we can use readerCaches instead.
  • Add retry logic when getTopicPolicies.

Documentation

  • no-need-doc

@Technoboy- Technoboy- changed the title [Branch 2.7] Fix TopicPoliciesCacheNotInitException issue. [Branch 2.7] [WIP] Fix TopicPoliciesCacheNotInitException issue. Feb 15, 2022
@mattisonchao mattisonchao changed the title [Branch 2.7] [WIP] Fix TopicPoliciesCacheNotInitException issue. [Branch 2.7] Fix TopicPoliciesCacheNotInitException issue. Feb 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-picked/branch-2.7 Archived: 2.7 is end of life release/2.7.5

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants