{"record":{"id":"688712a0da233681","repo":"apache/iceberg","slug":"metastore-operation-failed-for-s","errorCode":null,"errorMessage":"Metastore operation failed for %s","messagePattern":"Metastore operation failed for (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java","lineNumber":775,"sourceCode":"    // - Create meta files\n    // - Create the metadata in HMS, and this way committing the changes\n\n    // Create a new location based on the namespace / database if it is set on database level\n    String tableLocation = LocationUtil.tableLocation(tableIdentifier, uniqueTableLocation);\n    try {\n      Database databaseData =\n          clients.run(client -> client.getDatabase(tableIdentifier.namespace().levels()[0]));\n      if (databaseData.getLocationUri() != null) {\n        // If the database location is set use it as a base.\n        String databaseLocation = LocationUtil.stripTrailingSlash(databaseData.getLocationUri());\n        return String.format(\"%s/%s\", databaseLocation, tableLocation);\n      }\n\n    } catch (NoSuchObjectException e) {\n      throw new NoSuchNamespaceException(\n          e, \"Namespace does not exist: %s\", tableIdentifier.namespace().levels()[0]);\n    } catch (TException e) {\n      throw new RuntimeException(\n          String.format(\"Metastore operation failed for %s\", tableIdentifier), e);\n\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\"Interrupted during commit\", e);\n    }\n\n    // Otherwise, stick to the {WAREHOUSE_DIR}/{DB_NAME}.db/{TABLE_NAME} path\n    String databaseLocation = databaseLocation(tableIdentifier.namespace().levels()[0]);\n    return String.format(\"%s/%s\", databaseLocation, tableLocation);\n  }\n\n  private String databaseLocation(String databaseName) {\n    String warehouseLocation = conf.get(HiveConf.ConfVars.METASTOREWAREHOUSE.varname);\n    Preconditions.checkNotNull(\n        warehouseLocation, \"Warehouse location is not set: hive.metastore.warehouse.dir=null\");\n    warehouseLocation = LocationUtil.stripTrailingSlash(warehouseLocation);\n    return String.format(\"%s/%s.db\", warehouseLocation, databaseName);","sourceCodeStart":757,"sourceCodeEnd":793,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L757-L793","documentation":"Thrown by defaultWarehouseLocation when the metastore getDatabase call fails with a generic TException while computing the default warehouse location for a table. The RuntimeException message names the table identifier and wraps the Thrift cause. It reflects a metastore communication or server-side failure during location resolution.","triggerScenarios":"defaultWarehouseLocation (invoked during table create/load) hitting TException: HMS connection loss, thrift incompatibility, metastore internal error.","commonSituations":"HMS outage or restart during table creation; stale thrift connections after idle period; authentication/authorization errors surfacing as TException.","solutions":["Check the wrapped cause for the concrete TException and address it (connectivity, protocol, auth).","Verify HMS is reachable and healthy; retry the table operation with backoff.","Align client thrift/protocol versions with the HMS server version."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"try (Socket s = new Socket(hmsHost, hmsPort)) { /* HMS reachable before table ops */ }","typeGuard":null,"tryCatchPattern":"try {\n  catalog.createTable(ident, schema);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof TException) { /* backoff and retry; check HMS health */ }\n  throw e;\n}","preventionTips":["Retry table operations on transient thrift failures with backoff","Monitor HMS process health and thrift connection pool errors","Align iceberg-hive-metastore thrift versions with the HMS server"],"tags":["hive-metastore","thrift","connectivity","table-location"],"backgroundTag":"api-request-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}