diff --git a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java index ab84e990634e..f01f186dbf29 100644 --- a/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java +++ b/hadoop-ozone/recon/src/main/java/org/apache/hadoop/ozone/recon/spi/impl/ReconDBProvider.java @@ -121,6 +121,21 @@ static void truncateTable(Table table) throws IOException { KeyValue entry = tableIterator.next(); table.delete(entry.getKey()); } + } catch (Exception e) { + // Check if this is a closed database exception + if (e.getMessage() != null && e.getMessage().contains("closed")) { + // Log warning but don't fail if database is already closed + // This can happen during test cleanup or concurrent access scenarios + LOG.warn("Cannot truncate table {} - database is closed. " + + "Table may already be cleared or in process of being reinitialized.", + table.getName()); + return; + } + // Re-throw other exceptions as they indicate real problems + if (e instanceof IOException) { + throw (IOException) e; + } + throw new IOException("Failed to truncate table " + table.getName(), e); } }