{"record":{"id":"9056ab049c04ac16","repo":"unicity-aos/aos-ce","slug":"standalone-runtime-is-active-stop-it-before-migration","errorCode":null,"errorMessage":"standalone runtime is active; stop it before migration","messagePattern":"standalone runtime is active; stop it before migration","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/unicity-aos-bootstrap/src/migration.rs","lineNumber":175,"sourceCode":"                io::Error::new(\n                    io::ErrorKind::InvalidInput,\n                    \"standalone runtime has no existing system lock; refusing an unlocked migration\",\n                )\n            } else {\n                error\n            }\n        })?;\n        if path_metadata.file_type().is_symlink() || !path_metadata.is_file() {\n            return invalid(\"standalone runtime system lock must be a real regular file\");\n        }\n        let file = OpenOptions::new().read(true).write(true).open(&path)?;\n        let file_metadata = file.metadata()?;\n        if !file_metadata.is_file() || !same_file(&path_metadata, &file_metadata) {\n            return invalid(\"standalone runtime system lock changed while it was opened\");\n        }\n        file.try_lock_exclusive().map_err(|error| {\n            if error.kind() == io::ErrorKind::WouldBlock {\n                io::Error::new(\n                    io::ErrorKind::WouldBlock,\n                    \"standalone runtime is active; stop it before migration\",\n                )\n            } else {\n                error\n            }\n        })?;\n        Ok(Self { _file: file })\n    }\n}\n\n#[cfg(unix)]\nfn same_file(left: &fs::Metadata, right: &fs::Metadata) -> bool {\n    use std::os::unix::fs::MetadataExt;\n    left.dev() == right.dev() && left.ino() == right.ino()\n}\n\n#[cfg(not(unix))]","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/crates/unicity-aos-bootstrap/src/migration.rs#L157-L193","documentation":"`SourceRuntimeLock::acquire` opens `run/system.lock` and tries `try_lock_exclusive()`. If the OS returns `WouldBlock`, another process (the live standalone runtime) already holds the lock, so migration would race with a running runtime; the library raises `WouldBlock` with this message.","triggerScenarios":"Running the migration while the standalone runtime is still running and holding an exclusive lock on `run/system.lock`, or while a previous migration/service holds the file lock without having exited cleanly.","commonSituations":"Forgetting to stop the systemd unit or background daemon before migrating; another administrator or automation job migrating concurrently; a hung runtime process keeping the lock.","solutions":["Stop the standalone runtime (e.g. `systemctl stop <unit>` or the equivalent service command) so it releases `run/system.lock`, then re-run the migration.","Check for lingering processes holding the lock (`lsof <source>/run/system.lock` or `fuser`) and terminate them.","If the runtime was killed but a child still holds the fd, wait or reboot the host before migrating.","Serialize migrations through a job scheduler so only one migration runs at a time."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"let lock = source.join(\"run/system.lock\");\nif let Ok(f) = std::fs::File::open(&lock) {\n    if f.try_lock_exclusive().is_err() {\n        return Err(anyhow!(\"standalone runtime is active; stop it first\"));\n    }\n}","typeGuard":null,"tryCatchPattern":"match err.downcast_ref::<io::Error>() {\n    Some(e) if e.kind() == io::ErrorKind::WouldBlock && e.to_string().contains(\"runtime is active\") => stop_runtime_and_retry(),\n    _ => return Err(err),\n}","preventionTips":["Stop the runtime service before running any migration.","Check `lsof run/system.lock` for lingering holders before migrating.","Script the migration as stop -> migrate -> start."],"tags":["locking","migration","process","rust"],"backgroundTag":"resource-already-locked","analyzedSha":"f6f22024fb1e8d122f28a1b4a9f75aee448ae839","analyzedAt":"2026-09-13T03:04:44.565Z","contentChangedAt":"2026-09-13T03:04:44.565Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}