{"record":{"id":"35e61cf4e2537e83","repo":"apache/iceberg","slug":"interrupted-while-listing-databases","errorCode":null,"errorMessage":"Interrupted while listing databases","messagePattern":"Interrupted while listing databases","errorType":"exception","errorClass":"UncheckedInterruptedException","httpStatus":null,"severity":"warning","filePath":"snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java","lineNumber":225,"sourceCode":"    }\n\n    return true;\n  }\n\n  @Override\n  public List<SnowflakeIdentifier> listDatabases() {\n    List<SnowflakeIdentifier> databases;\n    try {\n      databases =\n          connectionPool.run(\n              conn ->\n                  queryHarness.query(\n                      conn, \"SHOW DATABASES IN ACCOUNT\", DATABASE_RESULT_SET_HANDLER));\n    } catch (SQLException e) {\n      throw snowflakeExceptionToIcebergException(\n          SnowflakeIdentifier.ofRoot(), e, \"Failed to list databases\");\n    } catch (InterruptedException e) {\n      throw new UncheckedInterruptedException(e, \"Interrupted while listing databases\");\n    }\n    databases.forEach(\n        db ->\n            Preconditions.checkState(\n                db.type() == SnowflakeIdentifier.Type.DATABASE,\n                \"Expected DATABASE, got identifier '%s'\",\n                db));\n    return databases;\n  }\n\n  @Override\n  public List<SnowflakeIdentifier> listSchemas(SnowflakeIdentifier scope) {\n    StringBuilder baseQuery = new StringBuilder(\"SHOW SCHEMAS\");\n    String[] queryParams = null;\n    switch (scope.type()) {\n      case ROOT:\n        // account-level listing\n        baseQuery.append(\" IN ACCOUNT\");","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java#L207-L243","documentation":"JdbcSnowflakeClient.listDatabases wraps InterruptedException from the 'SHOW DATABASES IN ACCOUNT' query into UncheckedInterruptedException. Listing failed because the thread was interrupted mid-query, usually by cancellation or shutdown rather than a data problem. SQLExceptions from the same query instead map to a generic IcebergException via snowflakeExceptionToIcebergException.","triggerScenarios":"Thread interrupted while running 'SHOW DATABASES IN ACCOUNT' through the JDBC query harness — e.g. engine task cancellation, executor shutdown, or timeout-triggered interrupts.","commonSituations":"Spark job cancelled while browsing namespaces in a UI/CLI, service shutdown during catalog warm-up, or health-check probes timing out and cancelling threads.","solutions":["Restore the interrupt flag (Thread.currentThread().interrupt()) when catching and abort","Investigate the cancellation source (job kill, shutdown hook, query timeout) and raise limits if premature","Retry listing once the environment is stable","Avoid issuing account-wide listing calls from threads subject to frequent interruption"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) {\n  throw new InterruptedException(\"Interrupted before listDatabases call\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  client.listDatabases();\n} catch (UncheckedInterruptedException e) {\n  Thread.currentThread().interrupt();\n  throw e;\n}","preventionTips":["Run account-wide listings on stable, long-lived threads","Restore the interrupt flag when handling this exception","Increase query timeouts if listings are being cut off prematurely","Cache database listings to reduce repeated interruptible JDBC calls"],"tags":["snowflake","interruption","threading"],"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"}