Repository navigation
ADFA-4951: EnvironmentLock primitive (foundation) - #303
Merged
Merged
Conversation
Introduce one app-wide coordination lock for deep-environment operations (module runrole, backup, restore, clone) so they never overlap over the rootfs. Ask EnvironmentLock.isHeld() — a POSITIVE signal — instead of 'is the server alive?', which is unsafe (an op that stops the server makes alive=false, so another op reads that as 'free to go' and collides). - EnvironmentLock: isBusyNow() (process-scoped: runrole + REST downloads, == legacy InstallJobs), isHeld(ctx) (adds the durable InstallGuard + a durable OWNER marker for backup/restore/clone), plus acquire()/release()/currentOwner()/heldSince(). - InstallJobs.isBusy() now delegates to EnvironmentLock.isBusyNow() (thin alias; callers unchanged). - Module/maps entry points (ModuleHubFragment, ModuleDetailFragment, MapsConfirmFragment) now check isHeld(ctx), so they also refuse while a durable install/owner op is in progress. - InstallGuard stays as-is (damaged-install recovery keys on it). Design doc: controller/docs/ENVIRONMENT_LOCK_AND_BACKUP_RESTORE.md. Follow-ups (same ticket): make InstallService/module acquire owner INSTALL/MODULE; migrate clone to acquire + stop the server (it clones live today) with a graceful stop/restart; then backup/restore (ADFA-4952) acquire BACKUP/RESTORE.
…orever Code-review follow-up (#303, suggestion 1). The durable owner marker had no staleness story: a BACKUP/CLONE killed mid-run would leave it, making isHeld() permanently true and blocking every deep-env op. Make the coordination lock SESSION-SCOPED — the marker carries a token unique to the process launch; a marker from a now-dead process reads as stale and self-heals (cleared) in ownerHeld(). After a kill no op is actually running, so the lock never stays held. Damage recovery stays separate: an interrupted WRITE op (half-applied restore/runrole) is recovered via the durable InstallGuard + its existing recovery, so a write op sets BOTH (lock + guard); read-only ops (backup, clone-send) set only the lock. Also synchronized the reads (currentOwner/heldSince/ownerHeld) — suggestion 2 — so they never race a write. Doc updated.
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.
What
One app-wide coordination lock for deep-environment operations (module runrole, backup, restore,
clone) so they never overlap over the rootfs. Ask
EnvironmentLock.isHeld()— a POSITIVE signal —instead of "is the server alive?", which is unsafe: an op that stops the server makes
alive=false,so another op reads that as "free to go" and collides.
Changes
EnvironmentLock(new):isBusyNow()(process-scoped: runrole + REST downloads — matches thelegacy
InstallJobs),isHeld(ctx)(adds the durableInstallGuard+ a durable OWNER marker forbackup/restore/clone), plus
acquire()/release()/currentOwner()/heldSince().InstallJobs.isBusy()now delegates toEnvironmentLock.isBusyNow()(thin alias; callers unchanged).ModuleHubFragment,ModuleDetailFragment,MapsConfirmFragment) checkisHeld(ctx), so they also refuse while a durable install/owner op is in progress.InstallGuardunchanged (damaged-install recovery keys on it).controller/docs/ENVIRONMENT_LOCK_AND_BACKUP_RESTORE.md.Foundation only — nothing acquires an owner yet. Follow-ups (same ticket):
InstallServiceacquiresINSTALL/MODULE; clone acquires + stops the server (it clones live today); then backup/restore
(ADFA-4952) acquire BACKUP/RESTORE.
Notes
Behavior-preserving refactor. Blocks ADFA-4952.