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

  1. Accept as normal shutdown behavior if the task was intentionally cancelled.
  2. If unexpected, investigate what interrupted the thread (job failover, timeout watchdog).
  3. Keep lock acquisition short — avoid slow transactions between tryLock attempts.
  4. 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

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


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