Closed
Description
OS Information
- OS: n/a
- Browser (if applicable):
- Architecture:
coder --version
: Coder v0.5.4-devel+d847d2b
Spotted while reading code
Steps to Reproduce
- execute "start" on a workspace from two clients simultaneously
Expected
one succeeds, other fails
Actual
sometimes, both can succeed
Logs
Screenshot
Notes
The issue is that coderd reads the DB to find the previous build, then later updates that build while adding a new build. The build could be updated and no longer be the latest during this time. What is needed is either:
- A query that finds and updates the latest build as well as adds the new build in a single transaction. This requires all "is this an allowed transition" logic to be build into the query.
- Start and hold open a transaction while doing multiple queries: reading the latest build, checking for errors, and finally writing the new build.