apache/iceberg · info · UncheckedInterruptedException

Interrupted during tryLock

Error message

Interrupted during tryLock

What it means

Thrown by JdbcLock.tryLock when the thread is interrupted while attempting to insert the lock row (acquire the maintenance lock) via the JDBC connection pool. The interrupt flag is restored and the exception is rethrown unchecked. The lock acquisition did not complete.

Source

Thrown at flink/v2.1/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

  1. Expected during job/task cancellation — verify shutdown was intentional
  2. If unexpected, find what interrupted the thread (executor shutdown, Flink cancel) and adjust lifecycle management
  3. Reduce lock contention so tryLock completes quickly (shorter maintenance windows, fewer concurrent triggers)
  4. After catching, ensure the interrupt flag is respected and do not loop retrying while interrupted
Defensive patterns

Strategy: try-catch

Try / catch

try {
  lock.tryLock();
} catch (UncheckedInterruptedException e) {
  Thread.currentThread().interrupt();
  // task is shutting down; do not retry while interrupted
}

Prevention

When it happens

Trigger: tryLock is invoked while the executing thread (Flink task thread or scheduler thread) receives an interrupt — e.g. task cancellation, thread pool shutdown during lock contention.

Common situations: Flink cancels the maintenance task while it waits on a contended lock insert; application shutdown while the lock is being acquired; executor service shutdown in embedded usage.

Related errors


AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12). Data as JSON: /api/errors/27e421203ea55c62. Report an issue: GitHub.