Avoid blocking auto-standby holds on persistence - #415
Open
sjmiller609 wants to merge 2 commits into
Open
Conversation
sjmiller609
marked this pull request as ready for review
August 17, 2026 13:56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
summary
why
Runtime metadata persistence can wait on instance storage while holding the controller-wide mutex. That delays unrelated auto-standby holds and adds latency before browser traffic can be forwarded.
tests
go test -race -count=10 ./lib/autostandbygo vet ./lib/autostandbygo test ./...(partial: packages unrelated to this change fail because embedded binaries andmkfs.erofsare unavailable;lib/autostandbypasses)Note
Medium Risk
Concurrency and ordering changes around idle/standby runtime metadata affect recovery across restarts and hold latency; behavior is localized to autostandby with targeted race tests but storage timing can still diverge briefly from in-memory state.
Overview
Auto-standby runtime persistence no longer holds the controller-wide mutex while
SetRuntimeruns, so slow instance storage cannot blockHoldStandbyor work on other instances.State updates still happen under the lock via
prepareRuntimePersistenceLocked, which stamps a generation and a per-instance serialization lock;persistRuntimeruns afterward, skips stale generations and deleted instances, and uses propagate vs best-effort error handling with operation labels in logs.Call sites across seed/resync, connection events, standby confirmation, standby execution, and active reconcile were refactored to unlock before persisting; connection handling can batch multiple persist jobs after one locked pass.
Regression tests cover cross-instance non-blocking, latest-generation wins, deleted-instance skip, and hold completing while persistence is in flight.
Reviewed by Cursor Bugbot for commit 118f11c. Bugbot is set up for automated code reviews on this repo. Configure here.