apache/iceberg · warning · UncheckedInterruptedException
Interrupted during tryLock
Error message
Interrupted during tryLock
What it means
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.
Source
Thrown at flink/v2.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java:199
try {
return pool.run(
conn -> {
try (PreparedStatement sql = conn.prepareStatement(CREATE_LOCK_SQL)) {
sql.setString(1, type.key);
sql.setString(2, lockId);
sql.setString(3, newInstanceId);
int count = sql.executeUpdate();
LOG.info(
"Created {} lock with instanceId {} with row count {}",
this,
newInstanceId,
count);
return count == 1;
}
});
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new UncheckedInterruptedException(e, "Interrupted during tryLock");
} catch (SQLException e) {
// SQL exception happened when creating the lock. Check if the lock creation was
// successful behind the scenes.
if (newInstanceId.equals(instanceId())) {
return true;
} else {
throw new UncheckedSQLException(e, "Failed to create %s lock", this);
}
}
}
@SuppressWarnings("checkstyle:NestedTryDepth")
@Override
public boolean isHeld() {
try {
return pool.run(
conn -> {
try (PreparedStatement sql = conn.prepareStatement(GET_LOCK_SQL)) {View on GitHub (pinned to 86d9c8fc54)
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.
Defensive patterns
Strategy: try-catch
Try / catch
try {
lock.tryLock();
} catch (UncheckedInterruptedException e) {
// interruption during lock acquisition; the flag is restored
throw e; // propagate to let the framework retry/cancel
} Prevention
- 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
When it happens
Trigger: Calling JdbcLock.tryLock (via TriggerLockFactory) while the thread is interrupted during pool.run of the INSERT that creates the lock row.
Common situations: Flink maintenance/commit operation cancelled or failed over mid-acquire, or shutdown hooks interrupting the worker thread while the DB call blocks.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- Interrupted in call to initialize
- Interrupted in SQL command
- Interrupted in SQL query
- Interrupted during commit
- Interrupted during unlock
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/841ab73109849a5a.
Report an issue: GitHub.