Skip to content

[WIP] fix: test multiple lifecycle executors flake #19456

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

bcpeinhardt
Copy link
Contributor

@bcpeinhardt bcpeinhardt commented Aug 20, 2025

Work in progress!
fixes coder/internal#455

This PR moves incrementing the workspace build number into the insert workspace build query so the operation is atomic.
I'm not exactly sure if this is the right fix yet.

Theory:
You can hit a race condition where the lifecycle executor takes a lock on the workspace, but it's only scoped to prevent multiple lifecycle executors from operating on the workspace at the same time:
ok, err := tx.TryAcquireLock(e.ctx, database.GenLockID(fmt.Sprintf("lifecycle-executor:%s", wsID)))
A manual action (like clicking "start workspace" or perhaps an API call in a concurrent build) can compete with a lifecycle executor.

I need to dig into how concurrent builds work to actually verify what's going on here.

Edit: the fix will probably involve moving the build_number field over to a serial type, it seems I just moved the race condition to the database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

flake: TestMultipleLifecycleExecutors
1 participant