codelipenghui commented on a change in pull request #14503:
URL: https://github.com/apache/pulsar/pull/14503#discussion_r816735623
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
##########
@@ -373,6 +361,18 @@ private void
initPolicesCache(SystemTopicClient.Reader<PulsarEvent> reader, Comp
});
}
+ private void cleanCacheAndCloseReader(NamespaceName namespace, boolean
cleanOwnedBundlesCount) {
+ CompletableFuture<SystemTopicClient.Reader<PulsarEvent>> readerFuture
= readerCaches.remove(namespace);
+ policyCacheInitMap.remove(namespace);
+ policiesCache.entrySet().removeIf(entry ->
entry.getKey().getNamespaceObject() == namespace);
+ if (cleanOwnedBundlesCount) {
+ ownedBundlesCountPerNamespace.remove(namespace);
+ }
+ if (readerFuture != null) {
Review comment:
Should check the `readerFuture` does not complete with exception.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
##########
@@ -382,10 +382,10 @@ private void
readMorePolicies(SystemTopicClient.Reader<PulsarEvent> reader) {
} else {
if (ex instanceof
PulsarClientException.AlreadyClosedException) {
log.error("Read more topic policies exception, close the
read now!", ex);
- NamespaceName namespace =
reader.getSystemTopic().getTopicName().getNamespaceObject();
- ownedBundlesCountPerNamespace.remove(namespace);
- readerCaches.remove(namespace);
+ cleanCacheAndCloseReader(
+
reader.getSystemTopic().getTopicName().getNamespaceObject(), false);
} else {
+ log.warn("Read more topic polices exception, read again.
{}", ex.getMessage());
Review comment:
Yes, it's better to have the stacktrace.
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java
##########
@@ -373,6 +361,18 @@ private void
initPolicesCache(SystemTopicClient.Reader<PulsarEvent> reader, Comp
});
}
+ private void cleanCacheAndCloseReader(NamespaceName namespace, boolean
cleanOwnedBundlesCount) {
Review comment:
Do we need to consider the thread-safe issue here?
--
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]