{"record":{"id":"b61407e313a05f5d","repo":"jdx/mise","slug":"another-history-operation-is-running","errorCode":null,"errorMessage":"another history operation is running","messagePattern":"another history operation is running","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/scope.rs","lineNumber":725,"sourceCode":"    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);\n    };\n    Ok(lock)\n}\n\n/// How long an operation waits for a running one, and how often it looks.\nconst OPERATION_LOCK_WAIT: std::time::Duration = std::time::Duration::from_secs(30);","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/scope.rs#L707-L743","documentation":"Same lock-acquisition path as the parameterized variant: when the deadline expires and store::read_marker_in finds no marker, acquire_operation_lock bails with the generic 'another history operation is running'. The lockfile is held but no marker was recorded.","triggerScenarios":"take_operation_lock_with_wait / recovery_lock timed out on a held LockFile::at(path) while no marker exists in the state dir — e.g. the holder crashed after locking but before writing its marker, or the marker file was deleted.","commonSituations":"Stale lockfile from a killed mise process; a holder that locked but died before writing the marker; racing processes on a shared MISE_STATE_DIR.","solutions":["Confirm no mise history process is alive (ps), then delete the stale lockfile in MISE_STATE_DIR and retry","Re-run the operation after ensuring only one mise instance runs","If crashes recur, check for SIGKILL/OOM during history operations"],"exampleFix":"// before: stale lock\nps aux | grep mise   # confirm nothing running\nrm \"$(mise state-dir)/history.lock\"   // after: remove stale lock, retry","handlingStrategy":"retry","validationCode":"if history.operation_lock_held() && !history.operation_marker_exists() {\n    eprintln!(\"stale lock without marker; safe to clear after confirming no mise process\");\n}","typeGuard":null,"tryCatchPattern":"match history.take_operation_lock() {\n    Err(e) if e.to_string() == \"another history operation is running\" => {\n        if !history.any_mise_process_alive() {\n            history.clear_stale_lock()?;\n            history.take_operation_lock()?;\n        }\n    }\n    other => other?,\n}","preventionTips":["Confirm no mise processes are alive before removing lockfiles","Prefer graceful termination (SIGTERM) so markers get written","Monitor for OOM kills that leave locks without markers"],"tags":["locking","concurrency","stale-lock","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"}