apache/iceberg · error · UncheckedSQLException

Failed to get lock information for

Error message

Failed to get lock information for %s

What it means

JdbcLockFactory.instanceId() wraps a SQLException raised while reading lock information rows from the JDBC catalog table in an UncheckedSQLException with message "Failed to get lock information for %s" (the lock Type). The maintenance lock could not be inspected, so lock acquisition cannot proceed safely.

Solutions

  1. Inspect the wrapped SQLException cause for the concrete DB error
  2. Verify the jdbc catalog initialization created the lock table and the user has SELECT rights
  3. Test connectivity with the same JDBC URL/credentials outside Flink
  4. Retry; transient DB issues resolve on the next maintenance cycle
Defensive patterns

Strategy: retry

Validate before calling

// preflight: lock table exists and is readable
try (Connection c = DriverManager.getConnection(jdbcUrl, user, pass);
     Statement s = c.createStatement()) { s.executeQuery("SELECT 1 FROM iceberg_lock"); }

Try / catch

try { ... instanceId path ... } catch (UncheckedSQLException e) { LOG.error("lock info read failed: {}", e.getCause()); }

Prevention

When it happens

Trigger: Calling JdbcLockFactory.create()/acquire paths that invoke instanceId() when the SELECT on the lock table fails: bad connection, missing lock table, SQL syntax/schema mismatch, deadlock or timeout.

Common situations: JDBC catalog URL or credentials misconfigured; lock table dropped or never initialized; DB under heavy load causing timeouts; permission denied on the lock table for the configured user.

Understand the failure class

Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.

Related errors


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

Appendix: source

Thrown at flink/v2.3/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java:303

        return pool.run(
            conn -> {
              try (PreparedStatement sql = conn.prepareStatement(GET_LOCK_SQL)) {
                sql.setString(1, type.key);
                sql.setString(2, lockId);
                try (ResultSet rs = sql.executeQuery()) {
                  if (rs.next()) {
                    return rs.getString(1);
                  } else {
                    return null;
                  }
                }
              }
            });
      } catch (InterruptedException e) {
        Thread.currentThread().interrupt();
        throw new UncheckedInterruptedException(e, "Interrupted during unlock");
      } catch (SQLException e) {
        throw new UncheckedSQLException(e, "Failed to get lock information for %s", type);
      }
    }
  }

  private enum Type {
    MAINTENANCE("m"),
    RECOVERY("r");

    private final String key;

    Type(String key) {
      this.key = key;
    }
  }
}

View on GitHub (pinned to 86d9c8fc54)