Exercise 3: Why force-unlock Requires Caution — Possible Solution ==================================================================== `terraform force-unlock` exists specifically because a crash mid-apply (the CI job dying, a network failure, a killed process) can leave a lock record sitting in DynamoDB with no corresponding apply left to ever release it -- since normal lock release only happens as part of an apply finishing cleanly. Without some way to clear that orphaned lock, every future apply would be permanently blocked by the "Error acquiring the state lock" message the chapter shows, indefinitely. The caution is warranted because force-unlock cannot actually tell the difference between two situations that look identical from the outside: (a) a lock left behind by something that has genuinely crashed and will never finish, which is safe to clear, and (b) a lock currently held by an apply that is simply still legitimately running -- a long apply provisioning many resources, for instance. Force-unlocking case (b) would remove the lock while that apply is still actively writing to state, opening the door to the EXACT concurrent-write corruption locking exists to prevent in the first place (per Exercises 1 and 2) -- now potentially worse, since one of the two "concurrent" writers is an apply that believes it still safely holds the lock. What should be verified before running it: confirm, through means outside Terraform's own locking mechanism (checking the CI system's job history/logs, checking with teammates, checking whether the process that acquired the lock is still actually running), that the apply which took out the lock has genuinely terminated and is not still in progress -- only then is clearing the lock actually safe. WHY THIS WORKS AS AN ANSWER ------------------------------ This explains the two situations force-unlock can't distinguish between (a genuinely crashed process vs. a legitimately still-running one) and why that ambiguity is exactly what makes it risky, then gives a concrete verification step (checking external evidence the lock mechanism itself can't provide) rather than a vague "be careful."