Question 600
A team needs to understand lock contention. The team must both keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock. Which paired choice implements those distinct goals?
Explanation
Correct Answer
For the first criterion, disabling locking increases risk of simultaneous updates and state corruption; it is not a substitute for resolving a stale lock; this behavior should be assessed against the concrete need to keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock; this directly addresses the need to keep concurrency protection during normal writes. For the separate second criterion, lock reports can include identifying information about the holder and operation; investigate the legitimate owner before overriding anything; this behavior should be assessed against the concrete need to keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock; this fulfills the need to diagnose whether another run or process holds a state lock. Together they cover the independent tasks of keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock without exchanging the responsibilities of these features.
Incorrect Answers
The second measure does meet the diagnose whether another run or process holds a state lock requirement, but the first is designed for another concern: Terraform may need to lock state for a safe plan or apply; a lock error is not itself an API authentication or HCL syntax error; this behavior should be assessed against the concrete need to keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock. That first component is designed to understand why a run can fail before any resource creation, which does not accomplish the requested task to keep concurrency protection during normal writes, even though the other measure satisfies diagnose whether another run or process holds a state lock.
The second measure does meet the diagnose whether another run or process holds a state lock requirement, but the first is designed for another concern: Force-unlock bypasses normal safeguards and can permit conflicting state writes; the lock ID helps ensure the intended lock is targeted; this behavior should be assessed against the concrete need to keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock. That first component is designed to clear a stale lock when the original owner is definitely inactive, which does not accomplish the requested task to keep concurrency protection during normal writes, even though the other measure satisfies diagnose whether another run or process holds a state lock.
The first measure is intended to verify that the selected backend actually coordinates operations: A remote backend may store state but have different locking capabilities; sharing storage is not proof that concurrent writers are safe; this behavior should be assessed against the concrete need to keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock. The second measure is intended to avoid interrupting an active legitimate Terraform operation: A lock usually means another process is modifying the same state; waiting is safer than forcing unlock while the first run is still active; this behavior should be assessed against the concrete need to keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock. Neither is the directly designated method for the separate goals of keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock in this review.
The first measure meets the requirement to keep concurrency protection during normal writes, but its partner serves a different role: Backends that support locking serialize state-changing operations; this guards consistency but does not replace change approval; this behavior should be assessed against the concrete need to keep concurrency protection during normal writes and diagnose whether another run or process holds a state lock. That second component is designed to prevent simultaneous runs from overwriting shared state, so the still-missing criterion is to diagnose whether another run or process holds a state lock, while the first criterion remains keep concurrency protection during normal writes.