{"record":{"id":"f8e0f7dcf09df1dd","repo":"jdx/mise","slug":"another-history-operation-is-running-since","errorCode":null,"errorMessage":"another history operation is running: {} since {} ({})","messagePattern":"another history operation is running: (.+?) since (.+?) \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/scope.rs","lineNumber":719,"sourceCode":"pub(crate) fn recovery_lock(store: &Store) -> Result<fslock::LockFile> {\n    acquire_operation_lock(store, std::time::Duration::ZERO)\n}\n\nfn acquire_operation_lock(store: &Store, wait: std::time::Duration) -> Result<fslock::LockFile> {\n    let state_dir = store.state_dir();\n    let path = store::operation_lock_in(state_dir);\n    // a running operation (the watcher applying incoming changes, say) is\n    // usually over in moments: wait for it a bounded while before failing\n    let deadline = std::time::Instant::now() + wait;\n    let mut announced = false;\n    let lock = loop {\n        if let Some(lock) = LockFile::at(&path).try_lock()? {\n            break lock;\n        }\n        let marker = store::read_marker_in(state_dir)?;\n        if std::time::Instant::now() >= deadline {\n            match marker {\n                Some(marker) => bail!(\n                    \"another history operation is running: {} since {} ({})\",\n                    marker.kind.as_str(),\n                    marker.started_at,\n                    marker.command\n                ),\n                None => bail!(\"another history operation is running\"),\n            }\n        }\n        if !announced {\n            announced = true;\n            info!(\n                \"history: waiting for another history operation to finish{}\",\n                marker\n                    .map(|marker| format!(\": {} ({})\", marker.kind.as_str(), marker.command))\n                    .unwrap_or_default()\n            );\n        }\n        std::thread::sleep(OPERATION_LOCK_POLL);","sourceCodeStart":701,"sourceCodeEnd":737,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/scope.rs#L701-L737","documentation":"acquire_operation_lock tries a non-blocking lock on the history operation lockfile, polling until a deadline. On timeout it reads the store's progress marker and, if one exists, reports which operation kind, start time, and command holds the lock instead of failing silently.","triggerScenarios":"Calling take_operation_lock_with_wait or recovery_lock while another history operation holds the lock and the wait deadline expires; the marker exists in the state dir with the holder's kind/started_at/command.","commonSituations":"Two mise processes running history operations concurrently (e.g. two shells, an IDE integration plus CLI); a previous crashed run left the lock/marker; a long-running operation exceeding the wait timeout.","solutions":["Wait for the running operation to finish, then retry","If the holder is dead (crashed/killed), remove the stale lock and marker from MISE_STATE_DIR and retry","Increase the wait deadline or serialize history operations in scripts"],"exampleFix":"// before: concurrent runs\nmise sync &\nmise pull &\n// after\nmise sync && mise pull","handlingStrategy":"retry","validationCode":"if history.operation_lock_held() {\n    eprintln!(\"waiting for running history operation before starting\");\n}","typeGuard":null,"tryCatchPattern":"match history.take_operation_lock_with_wait(deadline) {\n    Err(e) if e.to_string().starts_with(\"another history operation is running\") => {\n        // surface marker info to user; retry after holder exits\n        std::thread::sleep(Duration::from_secs(5));\n        retry_with_longer_deadline()?;\n    }\n    other => other?,\n}","preventionTips":["Don't run multiple mise history operations concurrently","Give long waits an adequate deadline","Check for crashed runs leaving locks before scripting operations"],"tags":["locking","concurrency","history"],"backgroundTag":"address-already-in-use","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}