You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by ma...@apache.org on 2025/04/02 03:58:55 UTC

(pulsar) branch branch-4.0 updated: [fix][misc]: ignore deleted ledger when tear down cluster (#23831)

This is an automated email from the ASF dual-hosted git repository.

mattisonchao pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new dd4b582f2c3 [fix][misc]: ignore deleted ledger when tear down cluster (#23831)
dd4b582f2c3 is described below

commit dd4b582f2c3d6a85e58afb9a0f49373b69859ba5
Author: Qiang Zhao <ma...@apache.org>
AuthorDate: Wed Mar 26 16:53:38 2025 +0800

    [fix][misc]: ignore deleted ledger when tear down cluster (#23831)
    
    (cherry picked from commit 3b3f915be6fbbfb0d3b905b88f45d51f634c5608)
---
 .../org/apache/pulsar/PulsarClusterMetadataTeardown.java  | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java
index 30a0dabea98..bd1c66610e6 100644
--- a/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java
+++ b/pulsar-broker/src/main/java/org/apache/pulsar/PulsarClusterMetadataTeardown.java
@@ -222,9 +222,18 @@ public class PulsarClusterMetadataTeardown {
             if (log.isDebugEnabled()) {
                 log.debug("Delete ledger id: {}", ledgerId);
             }
-        } catch (InterruptedException | BKException e) {
-            log.error("Failed to delete ledger {}: {}", ledgerId, e);
-            throw new RuntimeException(e);
+        } catch (InterruptedException | BKException ex) {
+            if (ex instanceof BKException bkException) {
+                switch (bkException.getCode()) {
+                    case BKException.Code.NoSuchLedgerExistsException:
+                    case BKException.Code.NoSuchLedgerExistsOnMetadataServerException:
+                        log.warn("Failed to delete deleted ledger. ledgerId={} errorCode={}",
+                                ledgerId, bkException.getCode());
+                        return;
+                }
+            }
+            log.error("Failed to delete ledger {}: {}", ledgerId, ex);
+            throw new RuntimeException(ex);
         }
     }