IssueRaiser

Terraform plan should not lock state files by default since it no longer writes changes to state

### Terraform Version ``` 0.14.8 ``` ### Expected Behavior `terraform plan` can be run simultaneously by multiple developers and parallel CI jobs such as will happen if pull/merge requests run `terraform plan` every time they are updated, prior to being merged, etc. ### Actual Behavior ``` Error: Error locking state: Error acquiring the state lock: writing "gs://<redacted>/default.tflock" failed: googleapi: Error 412: Precondition Failed, conditionNotMet Lock Info: ID: 1616009873855711 Path: gs://<redacted>/default.tflock Operation: OperationTypePlan Who: <redacted> Version: 0.14.8 Created: 2021-03-17 19:37:53.540992 +0000 UTC Info: Terraform acquires a state lock to protect the state from being written by multiple users at the same time. Please resolve the issue above and try again. For most commands, you can disable locking with the "-lock=false" flag, but this is not recommended. ``` ### Steps to Reproduce Run `terraform plan` on the same root module (with the same state) twice at the same time. ### Additional Context In an earlier time, running `terraform plan` would refresh state _and_ update remote state with those changes incrementing the serial number. As a result, state locking for `plan` was a hard requirement, otherwise one could experience an operation overwriting the state updates of another. Fast-forward to where we are today and the refresh `terraform plan` does is merely held in-memory, yet the state file is

Posted by davidalger on Mar 17, 2021, 8:01 PM

Tags

Related issues

Raise real-world problems, find people facing the same issue, and discuss solutions.3,000 issues0 comments

github (Other)

Terraform plan should not lock state files by default since it no longer writes changes to state

davidalgerMar 17, 2021, 8:01 PM

### Terraform Version ``` 0.14.8 ``` ### Expected Behavior `terraform plan` can be run simultaneously by multiple developers and parallel CI jobs such as will happen if pull/merge requests run `terraform plan` every time they are updated, prior to being merged, etc. ### Actual Behavior ``` Error: Error locking state: Error acquiring the state lock: writing "gs://<redacted>/default.tflock" failed: googleapi: Error 412: Precondition Failed, conditionNotMet Lock Info: ID: 1616009873855711 Path: gs://<redacted>/default.tflock Operation: OperationTypePlan Who: <redacted> Version: 0.14.8 Created: 2021-03-17 19:37:53.540992 +0000 UTC Info: Terraform acquires a state lock to protect the state from being written by multiple users at the same time. Please resolve the issue above and try again. For most commands, you can disable locking with the "-lock=false" flag, but this is not recommended. ``` ### Steps to Reproduce Run `terraform plan` on the same root module (with the same state) twice at the same time. ### Additional Context In an earlier time, running `terraform plan` would refresh state _and_ update remote state with those changes incrementing the serial number. As a result, state locking for `plan` was a hard requirement, otherwise one could experience an operation overwriting the state updates of another. Fast-forward to where we are today and the refresh `terraform plan` does is merely held in-memory, yet the state file is

Comments (0)

No comments yet. Start the discussion.

Comment on this issue