{"record":{"id":"bf689f7524af5fce","repo":"apache/iceberg","slug":"failed-to-create-namespace-namespace-in-hive-me","errorCode":null,"errorMessage":"Failed to create namespace ${namespace} in Hive Metastore","messagePattern":"Failed to create namespace (.+?) in Hive Metastore","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java","lineNumber":554,"sourceCode":"    Preconditions.checkArgument(\n        meta.get(HMS_DB_OWNER_TYPE) == null || meta.get(HMS_DB_OWNER) != null,\n        \"Create namespace setting %s without setting %s is not allowed\",\n        HMS_DB_OWNER_TYPE,\n        HMS_DB_OWNER);\n    try {\n      clients.run(\n          client -> {\n            client.createDatabase(convertToDatabase(namespace, meta));\n            return null;\n          });\n\n      LOG.info(\"Created namespace: {}\", namespace);\n\n    } catch (org.apache.hadoop.hive.metastore.api.AlreadyExistsException e) {\n      throw new AlreadyExistsException(e, \"Namespace already exists: %s\", namespace);\n\n    } catch (TException e) {\n      throw new RuntimeException(\n          \"Failed to create namespace \" + namespace + \" in Hive Metastore\", e);\n\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\n          \"Interrupted in call to createDatabase(name) \" + namespace + \" in Hive Metastore\", e);\n    }\n  }\n\n  @Override\n  public List<Namespace> listNamespaces(Namespace namespace) {\n    if (!namespace.isEmpty() && (!isValidateNamespace(namespace) || !namespaceExists(namespace))) {\n      throw new NoSuchNamespaceException(\"Namespace does not exist: %s\", namespace);\n    }\n    if (!namespace.isEmpty()) {\n      return ImmutableList.of();\n    }\n    try {","sourceCodeStart":536,"sourceCodeEnd":572,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L536-L572","documentation":"createNamespace wraps any generic Thrift TException from the Hive Metastore client in a RuntimeException indicating the namespace could not be created. This covers metastore connectivity, schema, or server-side failures that are not AlreadyExistsException.","triggerScenarios":"catalog.createNamespace(...) when the metastore client throws TException — e.g. connection failure, invalid database metadata (bad location URI), metastore-side errors during createDatabase.","commonSituations":"Metastore URIs misconfigured; metastore service down; invalid HDFS/Warehouse location or permissions for the new database path; Kerberos/auth failures surfacing as TException.","solutions":["Verify Hive Metastore connectivity (URI in catalog config, metastore service running) and inspect the chained cause","Check that the database location URI is valid and writable by the metastore user","Check authentication (Kerberos/DelegationTokens) between client and metastore","Retry after confirming the metastore is healthy; the error carries the underlying cause"],"exampleFix":"// before\ncatalog.createNamespace(Namespace.of(\"reports\"));\n// after\ntry {\n  catalog.createNamespace(Namespace.of(\"reports\"));\n} catch (RuntimeException e) {\n  LOG.error(\"Check metastore connectivity and cause\", e);\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// verify metastore reachability first\nclient.getAllDatabases(); // probe call before createNamespace","typeGuard":null,"tryCatchPattern":"try {\n  catalog.createNamespace(ns);\n} catch (RuntimeException e) {\n  LOG.error(\"createNamespace failed; cause: {}\", e.getCause(), e);\n  throw e;\n}","preventionTips":["Validate hive.metastore.uris config before running jobs","Ensure the database location URI is valid and writable","Check Kerberos/authentication setup","Keep metastore service monitored for availability"],"tags":["hive-metastore","thrift","namespace","connectivity"],"backgroundTag":"database-write-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"}