You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "lhotari (via GitHub)" <gi...@apache.org> on 2026/10/20 14:39:49 UTC

Re: [PR] [fix][broker] Don't continue loading a topic after its load has timed out [pulsar]

lhotari commented on code in PR #20540:
URL: https://github.com/apache/pulsar/pull/20540#discussion_r4326274121


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/AbstractTopic.java:
##########
@@ -1310,6 +1312,23 @@ public HierarchyTopicPolicies getHierarchyTopicPolicies() {
         return topicPolicies;
     }
 
+    @Override
+    public void registerTopicCacheCleanupFunction(TopicCacheCleanupFunction cleanupFunction) {
+        if (this.cleanupFunction != null) {

Review Comment:
   The PR has been rewritten on top of current master. The `TopicCacheCleanupFunction` is gone: master now removes cache entries only when they match the topic's exact create future (`getCreateFuture()`), which covers what it was for.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -3031,14 +3078,35 @@ private void createPendingLoadTopic() {
             });
         }).exceptionally(e -> {
             log.error("Failed to create pending topic {}", topic, e);
-            pendingTopic.getTopicFuture()
-                    .completeExceptionally((e instanceof RuntimeException && e.getCause() != null) ? e.getCause() : e);
+            Throwable cause = (e instanceof RuntimeException && e.getCause() != null) ? e.getCause() : e;
+            failTopicFuture(topic, pendingTopic.getTopicFuture(), cause);
             // schedule to process next pending topic
             inactivityMonitor.schedule(this::createPendingLoadTopic, 100, TimeUnit.MILLISECONDS);
             return null;
         });
     }
 
+    private void failPendingTopics() {
+        for (TopicLoadingContext topicLoadingContext = getNextPendingTopic(); topicLoadingContext != null;
+             topicLoadingContext = getNextPendingTopic()) {
+            topicLoadingContext.getTopicFuture()
+                    .completeExceptionally(new NotAllowedException("Broker is shutting down"));

Review Comment:
   Good point, addressed: the queued loads are now failed with `ServiceUnitNotReadyException`, so clients look the topic up again.



##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -3007,7 +3048,13 @@ private ConcurrentOpenHashMap<String, Object> getRuntimeConfigurationMap() {
      * permit if it was successful to acquire it.
      */
     private void createPendingLoadTopic() {
-        TopicLoadingContext pendingTopic = pendingTopicLoadingQueue.poll();
+        if (!pulsar().isRunning()) {
+            log.warn("Pulsar is not running, skip create pending topic");
+            failPendingTopics();

Review Comment:
   This code is gone in the rewrite. Queued loads are now failed once when the graceful bundle unload of a shutdown starts (the unload otherwise waits for their futures), and also when a load is queued after that.



-- 
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-unsubscribe@pulsar.apache.org

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