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 06:56:38 UTC

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

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


##########
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())) {

Review Comment:
   It's better to put `isLedgerNotExistException` into `NonRecoverableLedgerException`.



##########
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:
   Any known exception goes here? 



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