{"record":{"id":"e19d73d5b5a4a5cc","repo":"apache/iceberg","slug":"failed-to-get-lock-information-for-s-e19d73","errorCode":null,"errorMessage":"Failed to get lock information for %s","messagePattern":"Failed to get lock information for (.+?)","errorType":"exception","errorClass":"UncheckedSQLException","httpStatus":null,"severity":"error","filePath":"flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java","lineNumber":303,"sourceCode":"        return pool.run(\n            conn -> {\n              try (PreparedStatement sql = conn.prepareStatement(GET_LOCK_SQL)) {\n                sql.setString(1, type.key);\n                sql.setString(2, lockId);\n                try (ResultSet rs = sql.executeQuery()) {\n                  if (rs.next()) {\n                    return rs.getString(1);\n                  } else {\n                    return null;\n                  }\n                }\n              }\n            });\n      } catch (InterruptedException e) {\n        Thread.currentThread().interrupt();\n        throw new UncheckedInterruptedException(e, \"Interrupted during unlock\");\n      } catch (SQLException e) {\n        throw new UncheckedSQLException(e, \"Failed to get lock information for %s\", type);\n      }\n    }\n  }\n\n  private enum Type {\n    MAINTENANCE(\"m\"),\n    RECOVERY(\"r\");\n\n    private final String key;\n\n    Type(String key) {\n      this.key = key;\n    }\n  }\n}\n","sourceCodeStart":285,"sourceCodeEnd":319,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/flink/v2.1/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java#L285-L319","documentation":"Thrown by JdbcLock.instanceId when the SELECT that reads the current lock instance id for the given lock type fails with a SQLException. Callers (tryLock's post-failure check, unlock) cannot determine who holds the lock, so the original SQL error is wrapped in UncheckedSQLException.","triggerScenarios":"The lock-info SELECT fails: connection lost, lock table dropped/renamed, SELECT privilege missing, or SQL timeout while scanning the lock table.","commonSituations":"DB outage or connection pool exhaustion; manual schema changes removing the lock table; permission tightening on the maintenance user; timeout under heavy DB load.","solutions":["Read the wrapped SQLException (getCause) for the underlying SQL error","Verify the lock table exists with the expected schema and the user has SELECT rights","Check DB availability and connection pool health from the taskmanager","Retry after connectivity is restored; the lock state is unknown until this query succeeds"],"exampleFix":"// before: lock table manually dropped during maintenance\nDROP TABLE iceberg_lock; // instanceId query fails\n// after: recreate lock tables (restart JdbcLockFactory.initializeLockTables) and never drop while jobs run","handlingStrategy":"retry","validationCode":"// preflight lock table readability\ntry (Connection c = ds.getConnection();\n     ResultSet rs = c.createStatement().executeQuery(\n         \"SELECT instance_id FROM \" + lockTable + \" WHERE lock_id = ?\")) {\n  // OK\n} catch (SQLException e) { alert(\"Cannot read lock table: \" + e.getMessage()); }","typeGuard":null,"tryCatchPattern":"try {\n  triggerMaintenance();\n} catch (UncheckedSQLException e) {\n  if (isTableMissing(e)) { recreateLockTables(); }\n  else if (isTransient(e)) { backoffAndRetry(); }\n  else { throw e; }\n}","preventionTips":["Never drop or rename lock tables while maintenance jobs are configured","Keep SELECT grants on the lock tables for the runtime user","Use HA endpoints for the lock database and validate the connection pool regularly","Add monitoring on lock-table query latency to catch timeouts early"],"tags":["jdbc","sql","locking","database-query","flink"],"backgroundTag":"database-query-failed","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}