apache/iceberg · warning

Interrupted unlock we try one more time

Error message

Interrupted unlock we try one more time {}.{}

What it means

MetastoreLock.unlock() releases the Hive lock via doUnlock(id). If that call is interrupted but a lockId exists, this warning is logged and unlock is retried once after clearing the interrupt flag; the interrupt status is restored afterwards. This guards against leaking Hive locks when a shutdown interrupt lands exactly during unlock.

Solutions

  1. Check Hive (SHOW LOCKS) for leaked locks if the second unlock also failed, and unlock manually.
  2. Allow enough shutdown grace time (awaitTermination) so unlock RPCs finish before threads are interrupted.
  3. Retry the operation; Hive locks also expire, but manual cleanup avoids blocking other writers.
  4. Investigate why interrupt happened during unlock — usually premature shutdownNow() calls.

Example fix

// before: shutdownNow interrupts unlock RPC
pool.shutdownNow();
// after: let commits finish and release locks
pool.shutdown();
pool.awaitTermination(5, TimeUnit.MINUTES);
pool.shutdownNow();
Defensive patterns

Strategy: try-catch

Try / catch

try {
  lock.close(); // unlock
} catch (RuntimeException e) {
  // verify lock released via SHOW LOCKS; unlock manually if leaked
}

Prevention

When it happens

Trigger: unlock() (directly or recursively from acquireLock's failure path) is interrupted during the first doUnlock(id) call while id != null, triggering the one-retry path.

Common situations: Flink job cancellation or JVM shutdown racing with the release of a commit lock; long metastore RPC during unlock being interrupted by an aggressive shutdown timeout.

Related errors


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

Appendix: source

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

            return;
          }

          id = lockInfo.lockId;
        } else {
          LOG.warn("Could not find lock with HMSClient {}", HiveVersion.current());
          return;
        }
      } else {
        id = lockId.get();
      }

      doUnlock(id);
    } catch (InterruptedException ie) {
      if (id != null) {
        // Interrupted unlock. We try to unlock one more time if we have a lockId
        try {
          Thread.interrupted(); // Clear the interrupt status flag for now, so we can retry unlock
          LOG.warn("Interrupted unlock we try one more time {}.{}", databaseName, tableName, ie);
          doUnlock(id);
        } catch (Exception e) {
          LOG.warn("Failed to unlock even on 2nd attempt {}.{}", databaseName, tableName, e);
        } finally {
          Thread.currentThread().interrupt(); // Set back the interrupt status
        }
      } else {
        Thread.currentThread().interrupt(); // Set back the interrupt status
        LOG.warn("Interrupted finding locks to unlock {}.{}", databaseName, tableName, ie);
      }
    } catch (Exception e) {
      LOG.warn("Failed to unlock {}.{}", databaseName, tableName, e);
    }
  }

  private void doUnlock(long lockId) throws TException, InterruptedException {
    metaClients.run(
        client -> {

View on GitHub (pinned to 86d9c8fc54)