You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/09/27 08:38:57 UTC

[GitHub] [pulsar] AnonHxy commented on a diff in pull request #17842: [improve][broker]Improve PersistentMessageExpiryMonitor expire speed when ledger not existed

AnonHxy commented on code in PR #17842:
URL: https://github.com/apache/pulsar/pull/17842#discussion_r980935534


##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/persistent/PersistentMessageExpiryMonitor.java:
##########
@@ -191,9 +192,38 @@ public void findEntryFailed(ManagedLedgerException exception, Optional<Position>
                 && (exception instanceof NonRecoverableLedgerException)) {
             log.warn("[{}][{}] read failed from ledger at position:{} : {}", topicName, subName, failedReadPosition,
                     exception.getMessage());
-            findEntryComplete(failedReadPosition.get(), ctx);
+            if (isLedgerNotExistException(((NonRecoverableLedgerException) exception).getBkErrorCode())) {
+                try {
+                    long failedLedgerId = failedReadPosition.get().getLedgerId();
+                    Position lastPositionInLedger = PositionImpl.get(failedLedgerId,
+                            cursor.getManagedLedger().getLedgerInfo(failedLedgerId).get().getEntries() - 1);
+                    log.info("[{}][{}] ledger not existed, will complete the last position of the non-existed"
+                                    + " ledger:{}", topicName, subName, lastPositionInLedger);
+                    findEntryComplete(lastPositionInLedger, ctx);
+                } catch (Exception e) {

Review Comment:
   Yes.  `getLedgerInfo(failedLedgerId).get()` at line199 will throw exception and we must catch it



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