apache/iceberg · warning · UncheckedInterruptedException

Interrupted while checking if database

Error message

Interrupted while checking if database '%s' exists

What it means

JdbcSnowflakeClient.databaseExists wraps InterruptedException thrown while the JDBC query thread is interrupted into UncheckedInterruptedException. Interruption usually comes from task cancellation or shutdown (e.g. Spark/Flink cancelling a query, or a timeout cancelling the executor). The library re-interrupts/propagates so callers can honor cancellation semantics.

Solutions

  1. Preserve the interrupt status and stop the current operation gracefully; avoid swallowing InterruptedException
  2. Check what cancelled the task (query timeout, spark speculative execution, shutdown hook) and adjust timeouts
  3. Retry the operation after confirming the cancellation was spurious
  4. Avoid long-running work between submitting catalog calls and awaiting results on interruptible threads

Example fix

// before
boolean exists = client.databaseExists(SnowflakeIdentifier.ofDatabase("db"));
// after
try {
  boolean exists = client.databaseExists(SnowflakeIdentifier.ofDatabase("db"));
} catch (UncheckedInterruptedException e) {
  Thread.currentThread().interrupt();
  throw new IllegalStateException("Interrupted checking database existence; aborting", e);
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (Thread.currentThread().isInterrupted()) {
  throw new InterruptedException("Interrupted before databaseExists call");
}

Try / catch

try {
  client.databaseExists(db);
} catch (UncheckedInterruptedException e) {
  Thread.currentThread().interrupt();
  throw e;
}

Prevention

When it happens

Trigger: The thread executing databaseExists is interrupted while waiting on the JDBC connection/query result — typically via Future.cancel(true), executor shutdownNow, or query timeouts in Spark/Flink tasks.

Common situations: Spark task cancelled due to stage retry or speculative execution, application shutdown during catalog initialization, or a custom executor pool shutting down while catalog calls are in flight.

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/fad9cb3119c9ff8c. Report an issue: GitHub.

Appendix: source

Thrown at snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java:174

        "databaseExists requires a DATABASE identifier, got '%s'",
        database);

    final String finalQuery = "SHOW SCHEMAS IN DATABASE IDENTIFIER(?) LIMIT 1";

    List<SnowflakeIdentifier> schemas;
    try {
      schemas =
          connectionPool.run(
              conn ->
                  queryHarness.query(
                      conn, finalQuery, SCHEMA_RESULT_SET_HANDLER, database.databaseName()));
    } catch (SQLException e) {
      if (DATABASE_NOT_FOUND_ERROR_CODES.contains(e.getErrorCode())) {
        return false;
      }
      throw new UncheckedSQLException(e, "Failed to check if database '%s' exists", database);
    } catch (InterruptedException e) {
      throw new UncheckedInterruptedException(
          e, "Interrupted while checking if database '%s' exists", database);
    }

    return !schemas.isEmpty();
  }

  @Override
  public boolean schemaExists(SnowflakeIdentifier schema) {
    Preconditions.checkArgument(
        schema.type() == SnowflakeIdentifier.Type.SCHEMA,
        "schemaExists requires a SCHEMA identifier, got '%s'",
        schema);

    if (!databaseExists(SnowflakeIdentifier.ofDatabase(schema.databaseName()))) {
      return false;
    }

    final String finalQuery = "SHOW TABLES IN SCHEMA IDENTIFIER(?) LIMIT 1";

View on GitHub (pinned to 86d9c8fc54)