{"record":{"id":"9f35fc9b907b05c1","repo":"apache/iceberg","slug":"interrupted-while-getting-table-metadata-for-s","errorCode":null,"errorMessage":"Interrupted while getting table metadata for '%s'","messagePattern":"Interrupted while getting table metadata for '(.+?)'","errorType":"exception","errorClass":"UncheckedInterruptedException","httpStatus":null,"severity":"error","filePath":"snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java","lineNumber":353,"sourceCode":"        tableIdentifier);\n    SnowflakeTableMetadata tableMeta;\n    try {\n      final String finalQuery = \"SELECT SYSTEM$GET_ICEBERG_TABLE_INFORMATION(?) AS METADATA\";\n      tableMeta =\n          connectionPool.run(\n              conn ->\n                  queryHarness.query(\n                      conn,\n                      finalQuery,\n                      TABLE_METADATA_RESULT_SET_HANDLER,\n                      tableIdentifier.toIdentifierString()));\n    } catch (SQLException e) {\n      throw snowflakeExceptionToIcebergException(\n          tableIdentifier,\n          e,\n          String.format(\"Failed to get table metadata for '%s'\", tableIdentifier));\n    } catch (InterruptedException e) {\n      throw new UncheckedInterruptedException(\n          e, \"Interrupted while getting table metadata for '%s'\", tableIdentifier);\n    }\n    return tableMeta;\n  }\n\n  @Override\n  public void close() {\n    connectionPool.close();\n  }\n\n  private RuntimeException snowflakeExceptionToIcebergException(\n      SnowflakeIdentifier identifier, SQLException ex, String defaultExceptionMessage) {\n    // NoSuchNamespace exception for Database and Schema cases\n    if ((identifier.type() == SnowflakeIdentifier.Type.DATABASE\n            && DATABASE_NOT_FOUND_ERROR_CODES.contains(ex.getErrorCode()))\n        || (identifier.type() == SnowflakeIdentifier.Type.SCHEMA\n            && SCHEMA_NOT_FOUND_ERROR_CODES.contains(ex.getErrorCode()))) {\n      return new NoSuchNamespaceException(","sourceCodeStart":335,"sourceCodeEnd":371,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/snowflake/src/main/java/org/apache/iceberg/snowflake/JdbcSnowflakeClient.java#L335-L371","documentation":"JdbcSnowflakeClient.loadTableMetadata queries Snowflake for table metadata via JDBC. If the thread waiting on the JDBC call is interrupted, the InterruptedException is rethrown as an UncheckedInterruptedException so callers of the catalog API do not have to handle checked exceptions. This signals the calling thread's execution was cancelled mid-operation, typically during JVM or task shutdown.","triggerScenarios":"Calling loadTable/loadTableMetadata on a Snowflake table while the invoking thread's interrupt flag is set, e.g. during a Spark/Flink task cancellation, executor shutdown, or a future.cancel(true) while the JDBC query is in flight.","commonSituations":"Spark query cancellation kills running tasks and interrupts threads using the Snowflake catalog; application server shutdown interrupts in-flight catalog lookups; timeout frameworks interrupt worker threads that then call loadTable.","solutions":["Retain the interrupt status by calling Thread.currentThread().interrupt() in the wrapper or catch block before handling","Retry the loadTable call on a fresh, non-interrupted thread if cancellation was incidental","Move catalog initialization/metadata loading to a lifecycle phase that is not subject to interruption","Check for and remove sources of premature interruption (over-aggressive timeouts, executors shut down too early)"],"exampleFix":"// before\nTableMetadata meta = jdbcClient.loadTableMetadata(ident);\n// after\ntry {\n  TableMetadata meta = jdbcClient.loadTableMetadata(ident);\n} catch (UncheckedInterruptedException e) {\n  Thread.currentThread().interrupt();\n  throw e; // or retry if interruption was incidental\n}","handlingStrategy":"retry","validationCode":"if (Thread.currentThread().isInterrupted()) {\n  // resolve interruption state before issuing the JDBC-backed lookup\n}\nTableMetadata meta = catalog.loadTable(ident);","typeGuard":null,"tryCatchPattern":"try {\n  TableMetadata meta = catalog.loadTable(ident);\n} catch (UncheckedInterruptedException e) {\n  Thread.currentThread().interrupt();\n  throw new RuntimeException(\"Table metadata load cancelled: \" + ident, e);\n}","preventionTips":["Do not call catalog load methods from threads during shutdown","Use completion-based cancellation (futures without interrupt) when possible","Load table metadata once and cache it instead of re-querying under time pressure","Monitor interrupt status in long-running ETL frameworks"],"tags":["snowflake","jdbc","interrupted","concurrency"],"backgroundTag":"request-timeout","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}