{"record":{"id":"714f2b86f5f3da9d","repo":"apache/iceberg","slug":"failed-to-get-lock-information-for-s-714f2b","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.2/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.2/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java#L285-L319","documentation":"JdbcLockFactory.JdbcLock.instanceId() throws UncheckedSQLException when the SQL query to read lock information for the given lock type fails. The message names the lock type (task/recovery). This means the lock owner could not be determined due to a database access problem.","triggerScenarios":"instanceId() queries the lock table and the JDBC driver throws SQLException: connection failure, missing/renamed lock table, insufficient privileges, or unsupported SQL for the backend.","commonSituations":"Database outage or failover during maintenance; lock table absent because the JDBC catalog was never initialized; restricted DB user lacking SELECT on the lock table; using a JDBC backend whose SQL dialect differs from the expected pattern.","solutions":["Read the wrapped SQLException cause and restore database connectivity/health.","Verify the lock table exists with the expected schema for the given lock type prefix (m/r).","Grant the maintenance user read access to the lock table.","Validate your JDBC URL/credentials against the chosen database and re-run the maintenance trigger."],"exampleFix":"// before\nString url = \"jdbc:postgresql://db:5432/iceberg\"; // lock table missing\n// after\n// recreate catalog/lock tables or point to the catalog's database\nString url = \"jdbc:postgresql://db:5432/iceberg_catalog\";","handlingStrategy":"validation","validationCode":"try (Connection c = DriverManager.getConnection(jdbcUrl, user, pass)) {\n  ResultSet rs = c.getMetaData().getTables(null, null, \"iceberg_locks\", new String[]{\"TABLE\"});\n  if (!rs.next()) throw new IllegalStateException(\"Lock table missing\");\n}","typeGuard":null,"tryCatchPattern":"try { String id = lock.instanceId(); } catch (UncheckedSQLException e) { log.error(\"instanceId failed: {}\", e.getCause(), e); /* check lock table & DB health */ }","preventionTips":["Initialize the JDBC catalog so lock tables exist before enabling maintenance.","Verify user grants on the lock table for the maintenance account.","Confirm your JDBC backend supports the SQL used by JdbcLockFactory.","Alert on database failovers; re-run maintenance afterwards."],"tags":["jdbc","sql","lock","flink","database"],"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"}