{"record":{"id":"8734f6c7d1004cef","repo":"apache/iceberg","slug":"interrupted-in-call-to-initialize","errorCode":null,"errorMessage":"Interrupted in call to initialize","messagePattern":"Interrupted in call to initialize","errorType":"exception","errorClass":"UncheckedInterruptedException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java","lineNumber":229,"sourceCode":"\n    try {\n      atomicCreateTable(\n          JdbcUtil.CATALOG_TABLE_VIEW_NAME,\n          JdbcUtil.V0_CREATE_CATALOG_SQL,\n          \"to store iceberg catalog tables\");\n      atomicCreateTable(\n          JdbcUtil.NAMESPACE_PROPERTIES_TABLE_NAME,\n          JdbcUtil.CREATE_NAMESPACE_PROPERTIES_TABLE_SQL,\n          \"to store iceberg catalog namespace properties\");\n    } catch (SQLTimeoutException e) {\n      throw new UncheckedSQLException(e, \"Cannot initialize JDBC catalog: Query timed out\");\n    } catch (SQLTransientConnectionException | SQLNonTransientConnectionException e) {\n      throw new UncheckedSQLException(e, \"Cannot initialize JDBC catalog: Connection failed\");\n    } catch (SQLException e) {\n      throw new UncheckedSQLException(e, \"Cannot initialize JDBC catalog\");\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new UncheckedInterruptedException(e, \"Interrupted in call to initialize\");\n    }\n  }\n\n  private void updateSchemaIfRequired() {\n    try {\n      connections.run(\n          conn -> {\n            DatabaseMetaData dbMeta = conn.getMetaData();\n            try (ResultSet typeColumn =\n                dbMeta.getColumns(\n                    null, null, JdbcUtil.CATALOG_TABLE_VIEW_NAME, JdbcUtil.RECORD_TYPE)) {\n              if (typeColumn.next()) {\n                LOG.debug(\"{} already supports views\", JdbcUtil.CATALOG_TABLE_VIEW_NAME);\n                schemaVersion = JdbcUtil.SchemaVersion.V1;\n                return true;\n              } else {\n                if (PropertyUtil.propertyAsString(\n                        catalogProperties,","sourceCodeStart":211,"sourceCodeEnd":247,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/jdbc/JdbcCatalog.java#L211-L247","documentation":"Thrown by JdbcCatalog's initializeCatalogTables when the thread is interrupted while creating/initializing the JDBC catalog tables. The interrupt flag is re-set on the thread before throwing, preserving the interruption contract.","triggerScenarios":"The thread calling CatalogUtil.loadCatalog / JdbcCatalog.initialize() is interrupted (Thread.interrupt()) while blocking in connections.run(...) during catalog table creation — typically from executor shutdown, task cancellation, or a shutdown hook.","commonSituations":"Cancelling a Spark/Flink job that is initializing the catalog, shutting down an application server during startup, or a timeout framework interrupting slow initialization.","solutions":["Let the application shutdown/cancellation complete — the error is a signal, not a fault in the catalog","Retry initialization on a non-interrupted thread if interruption was accidental","Avoid interrupting threads that are inside JdbcCatalog.initialize(); check for stray Thread.interrupt() calls","Investigate why the task was cancelled (executor shutdown, future.cancel, watchdog)"],"exampleFix":"// before\nexecutor.shutdownNow(); // interrupts thread mid-initialize\n// after\nexecutor.shutdown();\nexecutor.awaitTermination(5, TimeUnit.MINUTES); // let initialize() finish first","handlingStrategy":"try-catch","validationCode":"if (Thread.currentThread().isInterrupted()) {\n  throw new IllegalStateException(\"thread already interrupted; skipping catalog init\");\n}","typeGuard":"boolean canInitialize() { return !Thread.currentThread().isInterrupted(); }","tryCatchPattern":"try {\n  catalog.initialize(name);\n} catch (UncheckedInterruptedException e) {\n  Thread.currentThread().interrupt(); // preserve flag, abort startup cleanly\n  return;\n}","preventionTips":["Do not interrupt threads that are inside JdbcCatalog.initialize()","Use executor.shutdown() + awaitTermination instead of shutdownNow() during startup","Check for watchdogs/futures.cancel(true) that could interrupt slow init","Retry initialization on a fresh thread if interruption was spurious"],"tags":["jdbc","interrupt","concurrency","catalog-init"],"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"}