Open
Description
I think there's a race condition in the GCS state mgr (and maybe others). It's a simple fix, but hard to write a unit test for... maybe some E2E test with some artificial waits would be better.
Anyways, the bug is here:
backend/remote-state/gcs/backend_state.go:134
The code initially checks if the state existed prior to grabbing the state lock, then grabs the lock, the creates the state (without checking if it exists). My question is: is it even possible to grab a state lock on a state that doesn't exist? If so, there's a race condition where the state doesn't exist, then something comes in, creates it and releases the lock, then it's overwritten with empty state.