apache/iceberg · error · RuntimeException

Interrupted in call to createDatabase(name) ${namespace} in

Error message

Interrupted in call to createDatabase(name) ${namespace} in Hive Metastore

What it means

createNamespace restores the interrupt flag and throws a RuntimeException when the thread is interrupted while executing the metastore createDatabase call via the retry client. It signals the operation was aborted due to thread interruption, not a metastore failure.

Source

Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/HiveCatalog.java:559

    try {
      clients.run(
          client -> {
            client.createDatabase(convertToDatabase(namespace, meta));
            return null;
          });

      LOG.info("Created namespace: {}", namespace);

    } catch (org.apache.hadoop.hive.metastore.api.AlreadyExistsException e) {
      throw new AlreadyExistsException(e, "Namespace already exists: %s", namespace);

    } catch (TException e) {
      throw new RuntimeException(
          "Failed to create namespace " + namespace + " in Hive Metastore", e);

    } catch (InterruptedException e) {
      Thread.currentThread().interrupt();
      throw new RuntimeException(
          "Interrupted in call to createDatabase(name) " + namespace + " in Hive Metastore", e);
    }
  }

  @Override
  public List<Namespace> listNamespaces(Namespace namespace) {
    if (!namespace.isEmpty() && (!isValidateNamespace(namespace) || !namespaceExists(namespace))) {
      throw new NoSuchNamespaceException("Namespace does not exist: %s", namespace);
    }
    if (!namespace.isEmpty()) {
      return ImmutableList.of();
    }
    try {
      List<Namespace> namespaces =
          clients.run(IMetaStoreClient::getAllDatabases).stream()
              .map(Namespace::of)
              .collect(Collectors.toList());

View on GitHub (pinned to 86d9c8fc54)

Solutions

  1. Avoid interrupting the thread; let the createNamespace call finish or cancel before shutdown
  2. Check your job/cancellation logic — handle the RuntimeException and re-check whether the database was actually created before retrying
  3. If intentional cancellation, catch the exception and exit cleanly (the interrupt flag is already restored)

Example fix

// before
executor.shutdownNow(); // interrupts in-flight createNamespace
// after
executor.shutdown();
executor.awaitTermination(5, TimeUnit.MINUTES);
Defensive patterns

Strategy: try-catch

Validate before calling

if (Thread.currentThread().isInterrupted()) {
  throw new InterruptedException("Skipping createNamespace: already interrupted");
}

Try / catch

try {
  catalog.createNamespace(ns);
} catch (RuntimeException e) {
  if (Thread.currentThread().isInterrupted()) {
    // intentional cancellation; exit cleanly
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Thread running catalog.createNamespace(...) is interrupted (e.g. task cancellation, executor shutdown, Spark job cancel) while the metastore call is in flight.

Common situations: Cancelling a Spark/Flink job mid-create; shutdown hooks interrupting worker threads; timeouts in orchestration frameworks that interrupt threads.

Understand the failure class

Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/36adebdda7400062. Report an issue: GitHub.