{"record":{"id":"d324ad8e8aa52701","repo":"apache/iceberg","slug":"failed-to-acquire-locks-from-metastore-because-the-d324ad","errorCode":null,"errorMessage":"Failed to acquire locks from metastore because the underlying metastore view 'HIVE_LOCKS' does not exist. This can occur when using an embedded metastore which does not support transactions. To fix this use an alternative metastore.","messagePattern":"Failed to acquire locks from metastore because the underlying metastore view 'HIVE_LOCKS' does not exist\\. This can occur when using an embedded metastore which does not support transactions\\. To fix this use an alternative metastore\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java","lineNumber":224,"sourceCode":"        throw new ValidationException(e, \"Invalid Hive object for %s.%s\", database, viewName);\n\n      } catch (CommitFailedException | CommitStateUnknownException e) {\n        throw e;\n\n      } catch (Throwable e) {\n        if (e.getMessage() != null\n            && e.getMessage()\n                .contains(\n                    \"The table has been modified. The parameter value for key '\"\n                        + BaseMetastoreTableOperations.METADATA_LOCATION_PROP\n                        + \"' is\")) {\n          throw new CommitFailedException(\n              e, \"The view %s.%s has been modified concurrently\", database, viewName);\n        }\n\n        if (e.getMessage() != null\n            && e.getMessage().contains(\"Table/View 'HIVE_LOCKS' does not exist\")) {\n          throw new RuntimeException(\n              \"Failed to acquire locks from metastore because the underlying metastore \"\n                  + \"view 'HIVE_LOCKS' does not exist. This can occur when using an embedded metastore which does not \"\n                  + \"support transactions. To fix this use an alternative metastore.\",\n              e);\n        }\n\n        LOG.error(\n            \"Cannot tell if commit to {}.{} succeeded, attempting to reconnect and check.\",\n            database,\n            viewName,\n            e);\n        commitStatus = BaseMetastoreOperations.CommitStatus.UNKNOWN;\n        commitStatus =\n            checkCommitStatus(\n                viewName,\n                newMetadataLocation,\n                metadata.properties(),\n                () -> checkCurrentMetadataLocation(newMetadataLocation));","sourceCodeStart":206,"sourceCodeEnd":242,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java#L206-L242","documentation":"The Hive metastore lacks the HIVE_LOCKS table, which Iceberg's locking relies on for transactional lock management. This is typical of an embedded/DERBY metastore or misconfigured metastore that does not support the transactional locking schema. Iceberg throws a RuntimeException wrapping the original Thrift exception.","triggerScenarios":"Any commit that needs to acquire a Hive lock while the metastore database does not contain the HIVE_LOCKS table; checkLock/acquireLock Thrift calls fail with \"Table/View 'HIVE_LOCKS' does not exist\".","commonSituations":"Using hive.metastore.warehouse with embedded Derby metastore in dev/test; a metastore initialized without transaction support; corrupted or wiped metastore schema.","solutions":["Switch to a real external metastore (e.g. backed by MySQL/PostgreSQL) with a properly initialized schema (schematool).","Run schematool -initSchema against the metastore DB so the transactional lock tables exist.","For test setups, disable Hive locking and rely on a different concurrency mechanism if the metastore cannot support it."],"exampleFix":"// before (hive-site.xml)\nhive.metastore.uris = \"\"   // embedded Derby\n\n// after\n<property><name>hive.metastore.uris</name><value>thrift://metastore-host:9083</value></property>\n<!-- metastore DB initialized via schematool -->","handlingStrategy":"validation","validationCode":"// run schematool against the metastore DB before starting jobs, or verify lock tables exist:\n// mysql> SHOW TABLES LIKE 'HIVE_LOCKS';\n// also confirm hive.metastore.uris points at a real metastore, not embedded Derby","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never use the embedded Derby metastore for concurrent Iceberg writes.","Initialize the metastore schema with schematool -initSchema before use.","Point hive.metastore.uris at an external metastore backed by MySQL/PostgreSQL."],"tags":["hive","metastore","locking","configuration"],"backgroundTag":"missing-dependency","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"}