apache/iceberg · warning
Interrupted while trying to find lock for table
Error message
Interrupted while trying to find lock for table {}.{} What it means
MetastoreLock.createLock() queries Hive for the existing lock while polling; if that wait is interrupted, the thread's interrupt status is restored, this warning is logged, and a LockException ("Interrupted while trying to find lock...") is thrown so the caller knows lock acquisition failed due to interruption. Unlike 3406, this path aborts instead of retrying.
Solutions
- Identify the interruption source (job cancel/shutdown) and retry the commit operation in a fresh thread.
- Release contending Hive locks (SHOW LOCKS, manual unlock) to shorten wait windows.
- Keep commit operations out of cancellation paths; complete or abort the transaction before shutdown.
- Clean up stale Hive locks from crashed sessions to reduce contention.
Example fix
// before: swallowing the LockException
try { table.commit(); } catch (LockException e) { /* ignore */ }
// after: surface and retry
try { table.commit(); } catch (LockException e) {
throw new RuntimeException("Commit lock failed for " + tableName, e);
} Defensive patterns
Strategy: retry
Try / catch
try {
lock.lock();
} catch (LockException e) {
if (e.getCause() instanceof InterruptedException) {
Thread.currentThread().interrupt(); // preserve status, retry later
}
} Prevention
- Use graceful cancellation so lock acquisition isn't interrupted mid-wait
- Release contending Hive locks promptly
- Clean up locks from crashed sessions
When it happens
Trigger: The thread executing lockInfo()/createLock()'s retry loop is interrupted while sleeping between checks for the Hive lock's state, hitting the InterruptedException branch after 'Failed to find lock for table'.
Common situations: Flink job cancellation during commit; executor shutdown; Hive locks held long by other transactions causing waits long enough to be interrupted by timeouts or cancels.
Related errors
- Interrupted while creating lock on table
- Interrupted while waiting for lock on table
- Interrupted unlock we try one more time
- Could not acquire the lock on
- Could not find lock with HMSClient
AI-assisted analysis of apache/iceberg@86d9c8fc54 (2026-09-12).
Data as JSON: /api/errors/88a02ac336a9b5b7.
Report an issue: GitHub.
Appendix: source
Thrown at hive-metastore/src/main/java/org/apache/iceberg/hive/MetastoreLock.java:328
try {
// If we can not check for lock, or we do not find it, then rethrow the exception
// Otherwise we are happy as the findLock sets the lockId and the state correctly
if (HiveVersion.min(HiveVersion.HIVE_2)) {
LockInfo lockFound = findLock();
if (lockFound != null) {
lockInfo.lockId = lockFound.lockId;
lockInfo.lockState = lockFound.lockState;
LOG.info("Found lock {} by agentInfo {}", lockInfo, agentInfo);
return;
}
}
throw new LockException(
"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);
}View on GitHub (pinned to 86d9c8fc54)