codelipenghui commented on code in PR #25148:
URL: https://github.com/apache/pulsar/pull/25148#discussion_r2696798971
##########
managed-ledger/src/main/java/org/apache/bookkeeper/mledger/impl/cache/RangeEntryCacheImpl.java:
##########
@@ -550,17 +556,31 @@ CompletableFuture<List<Entry>> readFromStorage(ReadHandle
lh, long firstEntry, l
ledgerEntries.close();
}
});
- // handle LH invalidation
- readResult.exceptionally(exception -> {
- if (exception instanceof BKException
- && ((BKException) exception).getCode() ==
BKException.Code.TooManyRequestsException) {
- } else {
+
+ return readResult.handle((entries, exception) -> {
+ if (exception == null) {
+ return CompletableFuture.completedFuture(entries);
+ }
+
+ Throwable cause = FutureUtil.unwrapCompletionException(exception);
+ if (allowRetry && cause instanceof
ManagedLedgerException.OffloadReadHandleClosedException) {
+ log.info("[{}] Read handle closed for ledger {}, reopening",
ml.getName(), lh.getId());
+ pendingReadsManager.invalidateLedger(lh.getId());
+ return ml.reopenReadHandle(lh.getId())
+ .thenCompose(reopened -> readFromStorage(reopened,
firstEntry, lastEntry, expectedReadCount,
+ false));
+ }
+
+ if (!(cause instanceof BKException
+ && ((BKException) cause).getCode() ==
BKException.Code.TooManyRequestsException)) {
ml.invalidateLedgerHandle(lh);
pendingReadsManager.invalidateLedger(lh.getId());
}
- return null;
- });
- return readResult;
+
+ CompletableFuture<List<Entry>> failed = new CompletableFuture<>();
+ failed.completeExceptionally(cause);
+ return failed;
Review Comment:
Fixed.
--
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]