Skip to content

fix: fix daemon.lock race on mutagen startup #101

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

Merged
merged 1 commit into from
May 14, 2025

Conversation

spikecurtis
Copy link
Collaborator

@spikecurtis spikecurtis commented May 13, 2025

I found the source of the issue where mutagen would fail to acquire the lock on daemon.lock at startup.

The MutagenClient attempts to lock the daemon.lock file while it is starting, so that it can fail fast if the daemon is not running.

While well meaning, this creates a race condition because as soon as we start the daemon process we create a MutagenClient so that we can talk to the daemon over its API. The MutagenClient might be holding the lock or have the lockfile open at the exact moment the daemon itself attempts to acquire and lock the file. The daemon immediately exits in that case and doesn't retry locking the file.

I've just removed the preflight checks on the daemon.lock, since we don't want Coder Desktop to ever mess with that file (outside of tests).

Copy link
Collaborator Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@spikecurtis spikecurtis requested a review from deansheather May 13, 2025 13:04
@spikecurtis spikecurtis self-assigned this May 13, 2025
@spikecurtis spikecurtis marked this pull request as ready for review May 13, 2025 13:04
@spikecurtis spikecurtis merged commit cd845d4 into main May 14, 2025
4 checks passed
@spikecurtis spikecurtis deleted the spike/daemon-startup-race branch May 14, 2025 05:58
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.

2 participants