{"record":{"id":"841ab73109849a5a","repo":"apache/iceberg","slug":"interrupted-during-trylock-841ab7","errorCode":null,"errorMessage":"Interrupted during tryLock","messagePattern":"Interrupted during tryLock","errorType":"exception","errorClass":"UncheckedInterruptedException","httpStatus":null,"severity":"warning","filePath":"flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java","lineNumber":199,"sourceCode":"      try {\n        return pool.run(\n            conn -> {\n              try (PreparedStatement sql = conn.prepareStatement(CREATE_LOCK_SQL)) {\n                sql.setString(1, type.key);\n                sql.setString(2, lockId);\n                sql.setString(3, newInstanceId);\n                int count = sql.executeUpdate();\n                LOG.info(\n                    \"Created {} lock with instanceId {} with row count {}\",\n                    this,\n                    newInstanceId,\n                    count);\n                return count == 1;\n              }\n            });\n      } catch (InterruptedException e) {\n        Thread.currentThread().interrupt();\n        throw new UncheckedInterruptedException(e, \"Interrupted during tryLock\");\n      } catch (SQLException e) {\n        // SQL exception happened when creating the lock. Check if the lock creation was\n        // successful behind the scenes.\n        if (newInstanceId.equals(instanceId())) {\n          return true;\n        } else {\n          throw new UncheckedSQLException(e, \"Failed to create %s lock\", this);\n        }\n      }\n    }\n\n    @SuppressWarnings(\"checkstyle:NestedTryDepth\")\n    @Override\n    public boolean isHeld() {\n      try {\n        return pool.run(\n            conn -> {\n              try (PreparedStatement sql = conn.prepareStatement(GET_LOCK_SQL)) {","sourceCodeStart":181,"sourceCodeEnd":217,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java#L181-L217","documentation":"JdbcLock.tryLock inserts a lock row through the connection pool; if the thread is interrupted while waiting on the pool/SQL, it re-interrupts the thread and throws UncheckedInterruptedException with this message. It indicates the job/task was cancelled while attempting to acquire the table-maintenance lock.","triggerScenarios":"Calling JdbcLock.tryLock (via TriggerLockFactory) while the thread is interrupted during pool.run of the INSERT that creates the lock row.","commonSituations":"Flink maintenance/commit operation cancelled or failed over mid-acquire, or shutdown hooks interrupting the worker thread while the DB call blocks.","solutions":["Accept as normal shutdown behavior if the task was intentionally cancelled.","If unexpected, investigate what interrupted the thread (job failover, timeout watchdog).","Keep lock acquisition short — avoid slow transactions between tryLock attempts.","Retry the lock acquisition in a fresh, non-interrupted thread/task."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  lock.tryLock();\n} catch (UncheckedInterruptedException e) {\n  // interruption during lock acquisition; the flag is restored\n  throw e; // propagate to let the framework retry/cancel\n}","preventionTips":["Keep tryLock attempts short to narrow the interrupt window","Don't run tryLock on threads you interrupt for other purposes","Investigate unexpected interrupts in the job scheduler"],"tags":["interrupt","jdbc","lock","concurrency"],"backgroundTag":"invalid-state-transition","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"}