World map

 

BM: Baca dalam Bahasa Melayu

World T3: State & Teams

Locking: one builder at a time

You will learn: why the register gets a busy sign, and what to do when it is stuck.

Checked with OpenTofu 1.13 on 1 Nov 2026

The problem

Aina’s tofu apply is halfway done. Ben starts his own apply on the same register. What should happen to Ben’s run?

Pick one answer.

Watch

bash
tofu plan
Error: Error acquiring the state lock
Error message: resource temporarily unavailable
Lock Info:
ID: 94da26d5-0aeb-a021-8eda-d41c2046f8f1
Path: terraform.tfstate
Operation: OperationTypeApply
Who: root@aina-laptop
Version: 1.13.5
Created: 2026-11-01 13:13:45.403003532 +0000 UTC
Info:
OpenTofu 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.
A real error. Ben's tofu plan stops with Error acquiring the state lock. The Lock Info shows an ID, the path terraform.tfstate, the operation OperationTypeApply and Who: root@aina-laptop.

A state lock: A busy sign on the register. While one run writes, another run stops with a lock error. is a “busy” sign on the register. Ben’s plan stopped at once. Nothing changed.

Try it

Who is building right now? Tap that line.

Tap the line that names who holds the lock.

0 of 1 found

Try it

Ben’s run hit a lock. Put his next steps in order.

First step at the top. Put these in order. Use the arrows, or drag.

  • Only if their run died: force-unlock with the ID
  • Wait for their run to finish, then try again
  • Ask that person, or check the pipeline
  • Read Who and Created in the error

Predict

Ben is in a hurry. Can he just add -lock=false?

Pick one answer.

Try it

Aina’s laptop crashed mid-apply. Her lock stayed behind. Build the careful fix.

Tap the pieces in the right order.

…

Check

Swipe: good teamwork, or needs work?

Swipe right for good, left for needs work. Or use the buttons.

1 / 4

Waited for Aina's apply to finish, then planned again

Waited for Aina's apply to finish, then planned again

You did it!

You can now read a lock error and free a stuck lock safely.

Go deeper (optional)

Most shared backends lock: s3 with use_lockfile = true, gcs, azurerm, pg. Terraform’s docs call DynamoDB locking for s3 deprecated; OpenTofu keeps both. The local backend uses the computer’s own file lock. That is how this real error happened: two runs on one machine.

Real rep (optional): two terminals, one folder, one register.

Real mission

  1. tofu init && tofu apply -auto-approve
  2. tofu apply
  3. tofu plan

0 of 4 steps done · Your ticks are saved.