apache/iceberg · warning

Interrupted while creating lock on table

Error message

Interrupted while creating lock on table {}.{}

What it means

MetastoreLock.createLock() issues the actual Hive lock-table creation call inside a retry block; if interrupted while creating the lock, the interrupt status is restored, this warning is logged, and a LockException ("Interrupted while creating lock on table...") propagates to the caller. The lock may or may not have been created in the metastore, so the caller should treat the transaction as not locked.

Solutions

  1. Retry the operation after determining whether a lock was actually created (check SHOW LOCKS for the table).
  2. Avoid interrupting threads inside the Iceberg commit critical section; cancel only between transactions.
  3. Handle the LockException by cleaning up any partially created lock before retrying.
  4. Increase metastore RPC timeouts so lock creation completes before shutdown windows close.

Example fix

// before: interrupting mid-commit
executor.shutdownNow(); // interrupts in-flight lock creation
// after: graceful shutdown
executor.shutdown();
executor.awaitTermination(5, TimeUnit.MINUTES);
Defensive patterns

Strategy: try-catch

Try / catch

try {
  lock.lock();
} catch (LockException e) {
  // check SHOW LOCKS for partially created lock, clean up, then retry
}

Prevention

When it happens

Trigger: The Hive client call that creates the lock (within the Tasks.retry body) throws InterruptedException because the calling thread was interrupted — usually during Flink job cancellation or executor shutdown.

Common situations: Application shutdown interrupting a commit in progress; thread-pool teardown while a write transaction is acquiring its Hive lock; long metastore RPCs making the lock call slow enough to overlap with cancellation.

Related errors


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

Appendix: source

Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/MetastoreLock.java:342

                      "Failed to find lock for table %s.%s", databaseName, tableName);
                } catch (InterruptedException e) {
                  Thread.currentThread().interrupt();
                  interrupted.set(true);
                  LOG.warn(
                      "Interrupted while trying to find lock for table {}.{}",
                      databaseName,
                      tableName,
                      e);
                  throw new LockException(
                      e,
                      "Interrupted while trying to find lock for table %s.%s",
                      databaseName,
                      tableName);
                }
              } catch (InterruptedException e) {
                Thread.currentThread().interrupt();
                interrupted.set(true);
                LOG.warn(
                    "Interrupted while creating lock on table {}.{}", databaseName, tableName, e);
                throw new LockException(
                    e, "Interrupted while creating lock on table %s.%s", databaseName, tableName);
              }
            },
            LockException.class);

    // This should be initialized always, or exception should be thrown.
    LOG.debug("Lock {} created for table {}.{}", lockInfo, databaseName, tableName);
    return lockInfo;
  }

  /**
   * Search for the locks using HMSClient.showLocks identified by the agentInfo. If the lock is
   * there, then a {@link LockInfo} object is returned. If the lock is not found <code>null</code>
   * is returned.
   *
   * @return The {@link LockInfo} for the found lock, or <code>null</code> if nothing found

View on GitHub (pinned to 86d9c8fc54)