{"record":{"id":"eeecef65bf97d93a","repo":"apache/iceberg","slug":"interrupted-in-call-to-initialize-eeecef","errorCode":null,"errorMessage":"Interrupted in call to initialize","messagePattern":"Interrupted in call to initialize","errorType":"exception","errorClass":"UncheckedInterruptedException","httpStatus":null,"severity":"warning","filePath":"flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java","lineNumber":158,"sourceCode":"            }\n            LOG.info(\"Creating Flink maintenance lock table {}\", LOCK_TABLE_NAME);\n            try (PreparedStatement ps = conn.prepareStatement(CREATE_LOCK_TABLE_SQL)) {\n              ps.execute();\n            }\n\n            return true;\n          });\n    } catch (SQLTimeoutException e) {\n      throw new UncheckedSQLException(\n          e, \"Cannot initialize JDBC table maintenance lock: Query timed out\");\n    } catch (SQLTransientConnectionException | SQLNonTransientConnectionException e) {\n      throw new UncheckedSQLException(\n          e, \"Cannot initialize JDBC table maintenance lock: Connection failed\");\n    } catch (SQLException e) {\n      throw new UncheckedSQLException(e, \"Cannot initialize JDBC table maintenance lock\");\n    } catch (InterruptedException e) {\n      Thread.currentThread().interrupt();\n      throw new UncheckedInterruptedException(e, \"Interrupted in call to initialize\");\n    }\n  }\n\n  private static class JdbcLock implements TriggerLockFactory.Lock {\n    private final JdbcClientPool pool;\n    private final String lockId;\n    private final Type type;\n\n    private JdbcLock(JdbcClientPool pool, String lockId, Type type) {\n      this.pool = pool;\n      this.lockId = lockId;\n      this.type = type;\n    }\n\n    @Override\n    public boolean tryLock() {\n      if (isHeld()) {\n        LOG.info(\"Lock is already held for {}\", this);","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java#L140-L176","documentation":"initializeLockTables runs statements through Tasks with retry inside JdbcClientPool; if the thread is interrupted while waiting/executing, the InterruptedException is re-flagged on the thread and wrapped in UncheckedInterruptedException with this message.","triggerScenarios":"JobManager/cancel-thread interruption during JdbcLockFactory.open(); task cancellation, job failover, or shutdown hitting while the lock-table initialization SQL is in flight.","commonSituations":"Job cancellation or restart while lock initialization is slow/blocked; manual cancel-with-savepoint during startup; JVM shutdown hooks interrupting worker threads.","solutions":["Treat as cancellation: if intentional, no action needed — the thread interrupt flag is restored.","If unexpected, investigate why initialization was slow (DB latency) to shrink the interrupt window.","Avoid cancelling jobs during startup; allow lock initialization to complete before triggering failover.","Check for hung JDBC connections causing long blocking calls that make interruptions likely."],"exampleFix":"// no code fix; operational guidance:\n// ensure DB reachable before starting the job so open() completes quickly and is not interrupted mid-way","handlingStrategy":"try-catch","validationCode":"// ensure thread interruption state is clear before opening\nif (Thread.currentThread().isInterrupted()) {\n    throw new IllegalStateException(\"Cannot open lock factory with interrupted thread\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    lockFactory.open();\n} catch (UncheckedInterruptedException e) {\n    Thread.currentThread().interrupt(); // preserve cancellation semantics\n    // shut down cleanly or rethrow to the cancellation handler\n}","preventionTips":["Avoid cancelling jobs during startup while lock init is in flight","Keep DB latency low so the interruptible window is small","Coordinate shutdown hooks so they don't interrupt initialization","Restore and check the interrupt flag when catching"],"tags":["jdbc","flink","interrupted","cancellation","maintenance-lock"],"backgroundTag":"thread-interrupted","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"}