You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "Technoboy- (via GitHub)" <gi...@apache.org> on 2023/04/23 02:16:18 UTC

[GitHub] [pulsar] Technoboy- commented on a diff in pull request #20130: [fix][broker] Fix deadlock in `ExtensibleLoadManagerImplTest.initializeState`

Technoboy- commented on code in PR #20130:
URL: https://github.com/apache/pulsar/pull/20130#discussion_r1174493752


##########
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/impl/AbstractMetadataStore.java:
##########
@@ -117,17 +118,19 @@ public CompletableFuture<List<String>> asyncReload(String key, List<String> oldV
                 .buildAsync(new AsyncCacheLoader<String, Boolean>() {
                     @Override
                     public CompletableFuture<Boolean> asyncLoad(String key, Executor executor) {
-                        return existsFromStore(key);
+                        // force jump to forkJoinThread to avoid callback execute on the metadataThread
+                        return existsFromStore(key).thenApplyAsync(Function.identity());
                     }
 
                     @Override
                     public CompletableFuture<Boolean> asyncReload(String key, Boolean oldValue,
                             Executor executor) {
                         if (isConnected) {
-                            return existsFromStore(key);
+                            // force jump to forkJoinThread to avoid callback execute on the metadataThread
+                            return existsFromStore(key).thenApplyAsync(Function.identity());
                         } else {
                             // Do not refresh if we're not connected
-                            return CompletableFuture.completedFuture(oldValue);
+                            return CompletableFuture.supplyAsync(() -> oldValue);

Review Comment:
   It's better to use the `executor` in this class.



-- 
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