{"record":{"id":"1564eb3acba32b07","repo":"apache/iceberg","slug":"namespace-delete-failed-s","errorCode":null,"errorMessage":"Namespace delete failed: %s","messagePattern":"Namespace delete failed: (.+?)","errorType":"exception","errorClass":"RuntimeIOException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java","lineNumber":350,"sourceCode":"    return Namespace.of(levels);\n  }\n\n  @Override\n  public boolean dropNamespace(Namespace namespace) {\n    Path nsPath = new Path(warehouseLocation, SLASH.join(namespace.levels()));\n\n    if (!isNamespace(nsPath) || namespace.isEmpty()) {\n      return false;\n    }\n\n    try {\n      if (fs.listStatusIterator(nsPath).hasNext()) {\n        throw new NamespaceNotEmptyException(\"Namespace %s is not empty.\", namespace);\n      }\n\n      return fs.delete(nsPath, false /* recursive */);\n    } catch (IOException e) {\n      throw new RuntimeIOException(e, \"Namespace delete failed: %s\", namespace);\n    }\n  }\n\n  @Override\n  public boolean setProperties(Namespace namespace, Map<String, String> properties) {\n    throw new UnsupportedOperationException(\n        \"Cannot set namespace properties \" + namespace + \" : setProperties is not supported\");\n  }\n\n  @Override\n  public boolean removeProperties(Namespace namespace, Set<String> properties) {\n    throw new UnsupportedOperationException(\n        \"Cannot remove properties \" + namespace + \" : removeProperties is not supported\");\n  }\n\n  @Override\n  public Map<String, String> loadNamespaceMetadata(Namespace namespace) {\n    Path nsPath = new Path(warehouseLocation, SLASH.join(namespace.levels()));","sourceCodeStart":332,"sourceCodeEnd":368,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/hadoop/HadoopCatalog.java#L332-L368","documentation":"HadoopCatalog.dropNamespace deletes a namespace directory from the warehouse location. If the underlying FileSystem.delete call throws an IOException for any reason other than a non-empty namespace, it is wrapped in this RuntimeIOException carrying the namespace name. The delete is non-recursive, so a partially-populated directory will fail loudly rather than cascade.","triggerScenarios":"Calling catalog.dropNamespace(Namespace) when fs.delete(nsPath, false) throws IOException — e.g. permission denied, the path was concurrently removed by another process, HDFS name-node unavailable, or a stale file handle.","commonSituations":"Distributed clusters where another job deletes the namespace path between the emptiness check and the delete; HDFS Safe Mode leaving the namespace in read-only state; misconfigured fs permissions on the warehouse location; network partitions to HDFS/S3.","solutions":["Check the cause exception (getCause()) to see the underlying FileSystem error and fix it (permissions, cluster availability, safe mode).","Re-check whether the namespace still exists before retrying; a concurrent delete may have already removed it.","Verify the caller has write/delete permission on the namespace directory and its parent.","Retry after the HDFS cluster / object store is healthy, since empty directories can also trip the NamespaceNotEmptyException path.","If namespaces frequently race with other writers, serialize namespace administration operations externally."],"exampleFix":"// before\ncatalog.dropNamespace(Namespace.of(\"reports\"));\n// after\ntry {\n  catalog.dropNamespace(Namespace.of(\"reports\"));\n} catch (RuntimeIOException e) {\n  LOG.warn(\"Namespace delete failed for reports: {}\", e.getCause());\n  // inspect cause: permissions, safe mode, concurrent delete\n}","handlingStrategy":"try-catch","validationCode":"Namespace ns = Namespace.of(\"db\");\nMap<String,String> meta = catalog.loadNamespaceMetadata(ns); // throws NoSuchNamespaceException if missing\n// confirm emptiness implicitly: dropNamespace throws NamespaceNotEmptyException if tables exist","typeGuard":"boolean canDrop = catalog.namespaceExists(ns) && catalog.loadNamespaceMetadata(ns) != null;","tryCatchPattern":"try {\n  catalog.dropNamespace(ns);\n} catch (NamespaceNotEmptyException e) {\n  // drop tables first\n} catch (RuntimeIOException e) {\n  Throwable cause = e.getCause(); // decide: permissions / concurrency / availability\n}","preventionTips":["Drop all tables in the namespace before dropping the namespace.","Run namespace administration on a single coordinator to avoid races with other writers.","Check HDFS health/safe mode before bulk catalog maintenance."],"tags":["io","filesystem","hadoop","catalog"],"backgroundTag":"file-delete-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}