Skip to content

Commit

Permalink
[fix][broker] fix ttl expiration block due to no-recoverable exceptio…
Browse files Browse the repository at this point in the history
…n even if autoSkipNonRecoverableData=true (#19132)
  • Loading branch information
aloyszhang authored Jan 8, 2023
1 parent c862356 commit badd69b
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerFencedException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerTerminatedException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.MetadataNotFoundException;
import org.apache.bookkeeper.mledger.ManagedLedgerException.NonRecoverableLedgerException;
import org.apache.bookkeeper.mledger.Position;
import org.apache.bookkeeper.mledger.impl.ManagedCursorContainer;
import org.apache.bookkeeper.mledger.impl.ManagedCursorImpl;
Expand Down Expand Up @@ -2858,7 +2859,14 @@ public boolean isOldestMessageExpired(ManagedCursor cursor, int messageTTLInSeco
(int) (messageTTLInSeconds * MESSAGE_EXPIRY_THRESHOLD), entryTimestamp);
}
} catch (Exception e) {
log.warn("[{}] Error while getting the oldest message", topic, e);
if (brokerService.pulsar().getConfiguration().isAutoSkipNonRecoverableData()
&& e instanceof NonRecoverableLedgerException) {
// NonRecoverableLedgerException means the ledger or entry can't be read anymore.
// if AutoSkipNonRecoverableData is set to true, just return true here.
return true;
} else {
log.warn("[{}] Error while getting the oldest message", topic, e);
}
} finally {
if (entry != null) {
entry.release();
Expand Down

0 comments on commit badd69b

Please sign in to comment.