{"record":{"id":"c4596c5ebab2c95b","repo":"apache/iceberg","slug":"interrupted-in-call-to-getdatabase-name-namespac","errorCode":null,"errorMessage":"Interrupted in call to getDatabase(name) <namespace> in Hive Metastore","messagePattern":"Interrupted in call to getDatabase\\(name\\) <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":686,"sourceCode":"\n  private void alterHiveDataBase(Namespace namespace, Database database) {\n    try {\n      clients.run(\n          client -> {\n            client.alterDatabase(namespace.level(0), database);\n            return null;\n          });\n\n    } catch (NoSuchObjectException | UnknownDBException e) {\n      throw new NoSuchNamespaceException(e, \"Namespace does not exist: %s\", namespace);\n\n    } catch (TException e) {\n      throw new RuntimeException(\n          \"Failed to list namespace under namespace: \" + namespace + \" in Hive Metastore\", e);\n\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new RuntimeException(\n          \"Interrupted in call to getDatabase(name) \" + namespace + \" in Hive Metastore\", e);\n    }\n  }\n\n  @Override\n  public Map<String, String> loadNamespaceMetadata(Namespace namespace) {\n    if (!isValidateNamespace(namespace)) {\n      throw new NoSuchNamespaceException(\"Namespace does not exist: %s\", namespace);\n    }\n\n    try {\n      Database database = clients.run(client -> client.getDatabase(namespace.level(0)));\n      Map<String, String> metadata = convertToMetadata(database);\n      LOG.debug(\"Loaded metadata for namespace {} found {}\", namespace, metadata.keySet());\n      return metadata;\n\n    } catch (NoSuchObjectException | UnknownDBException e) {\n      throw new NoSuchNamespaceException(e, \"Namespace does not exist: %s\", namespace);","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java#L668-L704","documentation":"Thrown by HiveCatalog.alterHiveDataBase when the thread is interrupted while waiting for a Hive Metastore client via the connection pool. The handler re-interrupts the current thread (restoring the interrupt flag) before throwing, so interruption is not swallowed. It means the caller (or an executor shutting down) cancelled the operation.","triggerScenarios":"Calling setProperties/removeProperties while the calling thread's interrupt flag is set or the interrupt arrives while clients.run(client -> client.getDatabase(...)) is acquiring/waiting for a pooled HMS client.","commonSituations":"Task cancelled by an executor/pool shutdown; Spark/Flink job cancellation propagating interrupts; query timeouts that interrupt worker threads.","solutions":["Find and remove the code that interrupts the thread (executor shutdown, timeout framework) or don't run catalog ops in interruptible contexts.","If intentional cancellation, treat this as expected and stop further catalog work.","Re-run the operation in a fresh, non-interrupted thread after confirming shutdown is not in progress."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) {\n  throw new IllegalStateException(\"Thread already interrupted; skipping catalog update\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  catalog.setProperties(ns, props);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof InterruptedException) { /* treat as cancellation, stop work */ }\n  throw e;\n}","preventionTips":["Don't run catalog mutations on threads owned by short-lived or cancellable executors","Check Thread.interrupted() before long catalog operations","Ensure shutdown hooks don't interrupt in-flight metadata updates"],"tags":["hive-metastore","interrupted","threading","namespace"],"backgroundTag":"request-timeout","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"}