{"record":{"id":"06b8a831f9f1a231","repo":"apache/iceberg","slug":"interrupted-while-checking-if-schema-s-exists","errorCode":null,"errorMessage":"Interrupted while checking if schema '%s' exists","messagePattern":"Interrupted while checking if schema '(.+?)' exists","errorType":"exception","errorClass":"UncheckedInterruptedException","httpStatus":null,"severity":"warning","filePath":"snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java","lineNumber":205,"sourceCode":"\n    if (!databaseExists(SnowflakeIdentifier.ofDatabase(schema.databaseName()))) {\n      return false;\n    }\n\n    final String finalQuery = \"SHOW TABLES IN SCHEMA IDENTIFIER(?) LIMIT 1\";\n\n    try {\n      connectionPool.run(\n          conn ->\n              queryHarness.query(\n                  conn, finalQuery, TABLE_RESULT_SET_HANDLER, schema.toIdentifierString()));\n    } catch (SQLException e) {\n      if (SCHEMA_NOT_FOUND_ERROR_CODES.contains(e.getErrorCode())) {\n        return false;\n      }\n      throw new UncheckedSQLException(e, \"Failed to check if schema '%s' exists\", schema);\n    } catch (InterruptedException e) {\n      throw new UncheckedInterruptedException(\n          e, \"Interrupted while checking if schema '%s' exists\", schema);\n    }\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\");","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java#L187-L223","documentation":"JdbcSnowflakeClient.schemaExists wraps InterruptedException raised while the schema existence JDBC query runs into UncheckedInterruptedException. It signals the calling thread was interrupted mid-check, typically by task cancellation or shutdown. Propagating it unchecked lets the surrounding engine honor cancellation.","triggerScenarios":"Thread interruption during the schemaExists JDBC query — from Spark/Flink task cancellation, executor shutdownNow, or a scheduling timeout cancelling catalog operations.","commonSituations":"Speculative execution cancelling duplicate Spark tasks, pod shutdown in Kubernetes mid-query, or a custom thread pool shutting down while catalog calls run.","solutions":["Catch UncheckedInterruptedException, restore the interrupt flag with Thread.interrupt(), and unwind","Identify and tune the source of cancellation (speculative execution, timeouts, shutdown sequencing)","Retry the existence check once the executor is stable","Keep catalog operations off threads you plan to shut down abruptly"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) {\n  throw new InterruptedException(\"Interrupted before schemaExists call\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  client.schemaExists(schemaId);\n} catch (UncheckedInterruptedException e) {\n  Thread.currentThread().interrupt();\n  throw e;\n}","preventionTips":["Restore interrupt status when wrapping InterruptedException as unchecked","Avoid speculative execution or timeouts that interrupt catalog-bound tasks","Perform catalog lookups before entering cancel-prone execution phases","Use graceful shutdown for pools running catalog operations"],"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"}