poorbarcode commented on code in PR #25293:
URL: https://github.com/apache/pulsar/pull/25293#discussion_r2903000976


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/transaction/buffer/impl/TableView.java:
##########
@@ -48,7 +49,20 @@ public class TableView<T> {
     protected final Function<TopicName, CompletableFuture<Reader<T>>> 
readerCreator;
     private final Map<String, T> snapshots = new ConcurrentHashMap<>();
     private final long clientOperationTimeoutMs;
-    private final SimpleCache<NamespaceName, Reader<T>> readers;
+    private final SimpleCache<NamespaceName, CompletableFuture<Reader<T>>> 
readers;
+    private final Consumer<CompletableFuture<Reader<T>>> expiration = 
readerFuture -> {
+        if (!readerFuture.isDone()) {
+            readerFuture.handle((reader, t) -> {
+                if (reader != null) {
+                    closeReader(reader);
+                }
+                return null;
+            });
+        } else if (!readerFuture.isCompletedExceptionally()) {
+            // Since the future has done, it will not wait anymore.
+            closeReader(readerFuture.join());

Review Comment:
   The default value of `clientOperationTimeoutMs` is 30s(we have not change 
it), and `CACHE_EXPIRE_TIMEOUT_MS` is 60s
   
   The code was modified to ensure that the original behavior would not change 
and that there would never be `clientOperationTimeoutMs` situation where 
`CACHE_EXPIRE_TIMEOUT_MS` is greater than B
   
   
   > the cache entry is removed or expired before the future completes
   > the future completes successfully after expiration and should close the 
reader exactly once
   
   These two cases will never happen



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

Reply via email to