{"record":{"id":"0b36d195971a8e40","repo":"apache/iceberg","slug":"the-view-s-s-has-been-modified-concurrently","errorCode":null,"errorMessage":"The view %s.%s has been modified concurrently","messagePattern":"The view (.+?)\\.(.+?) has been modified concurrently","errorType":"exception","errorClass":"CommitFailedException","httpStatus":null,"severity":"error","filePath":"hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java","lineNumber":218,"sourceCode":"                + \"iceberg.hive.lock-heartbeat-interval-ms.\",\n            le);\n      } catch (org.apache.hadoop.hive.metastore.api.AlreadyExistsException e) {\n        throw new AlreadyExistsException(e, \"View already exists: %s.%s\", database, viewName);\n\n      } catch (InvalidObjectException e) {\n        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;","sourceCodeStart":200,"sourceCodeEnd":236,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/hive-metastore/src/main/java/org/apache/iceberg/hive/HiveViewOperations.java#L200-L236","documentation":"HiveViewOperations.doCommit detected that the Hive metastore view's metadata_location parameter was changed by another writer between read and commit. Iceberg re-checks the metadata location on commit to enforce compare-and-swap semantics; a mismatch means a concurrent commit succeeded first. The current commit is rejected and should be retried by the caller.","triggerScenarios":"Calling a commit (e.g. table/view refresh that appends or alters the view) while another process commits to the same view; the underlying TException message contains \"The table has been modified. The parameter value for key 'metadata_location' is ...\".","commonSituations":"Two Spark/Flink jobs or engines writing the same Iceberg view simultaneously; a manually altered or restored Hive view; stale client cache reading an old metadata location.","solutions":["Refresh the view and re-apply the operation; the commit is safe to retry after rebase.","Ensure only one writer commits at a time or serialize writes through a job scheduler.","Verify no external tooling (e.g. manual ALTER VIEW or metastore edits) changes metadata_location outside Iceberg."],"exampleFix":"// before\nview.refresh();\nsql(\"CREATE OR REPLACE VIEW ...\") run concurrently by two jobs\n\n// after\nretryLoop:\n  try {\n    view.refresh(); // pick up latest version\n    view.updateSQL().set(\"SELECT * FROM t WHERE day < '2026-01-01'\").commit();\n    break retryLoop;\n  } catch (CommitFailedException e) {\n    // backoff and retry with fresh metadata\n  }","handlingStrategy":"retry","validationCode":"// before committing, confirm metadata hasn't moved underneath you\nString current = (String) catalog.loadView(ident).properties()\n    .get(BaseMetastoreTableOperations.METADATA_LOCATION_PROP);\nif (!expectedMetadataLocation.equals(current)) {\n  view.refresh(); // pick up concurrent commit before re-trying\n}","typeGuard":null,"tryCatchPattern":"try {\n  view.updateSQL()...commit();\n} catch (CommitFailedException e) {\n  view.refresh();\n  // re-apply changes and retry with backoff\n}","preventionTips":["Always refresh the view before applying updates.","Avoid multiple concurrent writers to the same view; serialize commits.","Never ALTER the Hive view's metadata_location manually outside Iceberg."],"tags":["hive","concurrency","commit-conflict","metastore"],"backgroundTag":"invalid-state-transition","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"}