[fix][broker] fix ttl expiration block due to no-recoverable exception even if autoSkipNonRecoverableData=true
@@ -67,6 +67,7 @@ import org.apache.bookkeeper.mledger.ManagedLedgerException.ManagedLedgerAlready
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;
@@ -2858,7 +2859,14 @@ public class PersistentTopic extends AbstractTopic implements Topic, AddEntryCal
(int) (messageTTLInSeconds * MESSAGE_EXPIRY_THRESHOLD), entryTimestamp);
}
} catch (Exception 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();
