{"record":{"id":"8002fd59ad619603","repo":"apache/iceberg","slug":"failed-to-get-lock-information-for-s","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/v1.20/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/v1.20/flink/src/main/java/org/apache/iceberg/flink/maintenance/api/JdbcLockFactory.java#L285-L319","documentation":"JdbcLockFactory.instanceId() could not read/write lock information in the JDBC lock table while computing a unique instance id; the SQLException is wrapped into UncheckedSQLException with this message. No instance id could be established, so trigger locking cannot proceed.","triggerScenarios":"SQLException during instanceId()'s lock-table access: database unreachable, lock table missing, INSERT/SELECT denied, or duplicate/unique-key conflict on lock rows during concurrent startup.","commonSituations":"First run before the lock table was created; two task managers starting concurrently against a DB with restrictive isolation; credentials valid for SELECT but not INSERT; JDBC URL pointing at a nonexistent database.","solutions":["Create the JDBC lock table with the schema expected by JdbcCatalog/JdbcLockFactory before enabling maintenance.","Validate JDBC URL, user and password against the target database with a SQL client.","Grant the JDBC user SELECT/INSERT/UPDATE/DELETE on the lock table.","Retry startup if concurrent instance allocation caused a transient conflict; stagger task manager starts.","Read UncheckedSQLException.getCause() for the exact driver error message."],"exampleFix":"// before\nJdbcLockFactory.builder().setJdbcUrl(\"jdbc:postgresql://host:5432/iceberg\") // lock table never created\n  .build();\n// after\n// run first: CREATE TABLE iceberg.maintenance_lock (...) per JdbcCatalog docs\nJdbcLockFactory.builder().setJdbcUrl(\"jdbc:postgresql://host:5432/iceberg\").build();","handlingStrategy":"validation","validationCode":"try (Connection c = DriverManager.getConnection(jdbcUrl, user, pass)) {\n  DatabaseMetaData md = c.getMetaData();\n  if (!md.getTables(null, null, \"trigger_lock\", null).next()) {\n    throw new IllegalStateException(\"Lock table missing - run init SQL\");\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  factory.tableTriggerLock(...);\n} catch (UncheckedSQLException e) {\n  LOG.error(\"instanceId allocation failed\", e.getCause());\n  // retry with backoff once the DB/table is fixed\n}","preventionTips":["Create the lock table before first maintenance run","Grant full DML on the lock table to the JDBC user","Verify database name in the JDBC URL exists","Stagger concurrent task-manager startups to avoid lock-row races"],"tags":["flink","jdbc","lock","sql","instance-id"],"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"}