Skip to content

Commit 1e55dc0

Browse files
mattisonchaosrinath-ctds
authored andcommitted
[fix][misc]: ignore deleted ledger when tear down cluster (apache#23831)
(cherry picked from commit 3b3f915) (cherry picked from commit dd4b582)
1 parent 05de7ce commit 1e55dc0

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,18 @@ private static void deleteLedger(BookKeeper bookKeeper, long ledgerId) {
222222
if (log.isDebugEnabled()) {
223223
log.debug("Delete ledger id: {}", ledgerId);
224224
}
225-
} catch (InterruptedException | BKException e) {
226-
log.error("Failed to delete ledger {}: {}", ledgerId, e);
227-
throw new RuntimeException(e);
225+
} catch (InterruptedException | BKException ex) {
226+
if (ex instanceof BKException bkException) {
227+
switch (bkException.getCode()) {
228+
case BKException.Code.NoSuchLedgerExistsException:
229+
case BKException.Code.NoSuchLedgerExistsOnMetadataServerException:
230+
log.warn("Failed to delete deleted ledger. ledgerId={} errorCode={}",
231+
ledgerId, bkException.getCode());
232+
return;
233+
}
234+
}
235+
log.error("Failed to delete ledger {}: {}", ledgerId, ex);
236+
throw new RuntimeException(ex);
228237
}
229238
}
230239

0 commit comments

Comments
 (0)