BewareMyPower commented on code in PR #24658:
URL: https://github.com/apache/pulsar/pull/24658#discussion_r2296723864


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/SystemTopicBasedTopicPoliciesService.java:
##########
@@ -526,32 +533,39 @@ private void 
initPolicesCache(SystemTopicClient.Reader<PulsarEvent> reader, Comp
         });
     }
 
-    private void cleanCacheAndCloseReader(@NonNull NamespaceName namespace, 
boolean cleanOwnedBundlesCount) {
-        cleanCacheAndCloseReader(namespace, cleanOwnedBundlesCount, false);
+    private void cleanCache(@NonNull NamespaceName namespace, boolean 
cleanOwnedBundlesCount,
+                            boolean closeReaderCache) {
+        cleanCache(namespace, cleanOwnedBundlesCount, false, closeReaderCache);
     }
 
-    private void cleanCacheAndCloseReader(@NonNull NamespaceName namespace, 
boolean cleanOwnedBundlesCount,
-                                          boolean cleanWriterCache) {
+    private void cleanCache(@NonNull NamespaceName namespace, boolean 
cleanOwnedBundlesCount,
+                            boolean cleanWriterCache, boolean 
cleanReaderCache) {
         if (cleanWriterCache) {
             writerCaches.synchronous().invalidate(namespace);
         }
-        CompletableFuture<SystemTopicClient.Reader<PulsarEvent>> readerFuture 
= readerCaches.remove(namespace);
 
         if (cleanOwnedBundlesCount) {
             ownedBundlesCountPerNamespace.remove(namespace);
         }
-        if (readerFuture != null && !readerFuture.isCompletedExceptionally()) {
-            readerFuture.thenCompose(SystemTopicClient.Reader::closeAsync)
-                    .exceptionally(ex -> {
-                        log.warn("[{}] Close change_event reader fail.", 
namespace, ex);
-                        return null;
-                    });
+
+        if (!cleanReaderCache) {
+            policyCacheInitMap.remove(namespace);

Review Comment:
   Removing the cache from `policyCacheInitMap` could trigger the reader 
creation again.
   
   ```java
                               return 
policyCacheInitMap.computeIfAbsent(namespace, (k) -> {
                                   final 
CompletableFuture<SystemTopicClient.Reader<PulsarEvent>> 
readerCompletableFuture =
                                           createSystemTopicClient(namespace);
                                   readerCaches.put(namespace, 
readerCompletableFuture);
   ```



-- 
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: commits-unsubscr...@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to