{"record":{"id":"64dfe0d16f6f691f","repo":"openai/codex","slug":"wouldblock-64dfe0","errorCode":"WouldBlock","errorMessage":"could not acquire exclusive lock on history file after multiple attempts","messagePattern":"could not acquire exclusive lock on history file after multiple attempts","errorType":"exception","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/message-history/src/lib.rs","lineNumber":181,"sourceCode":"            match history_file.try_lock() {\n                Ok(()) => {\n                    // While holding the exclusive lock, write the full line.\n                    // We do not open the file with `append(true)` on Windows, so ensure the\n                    // cursor is positioned at the end before writing.\n                    history_file.seek(SeekFrom::End(0))?;\n                    history_file.write_all(line.as_bytes())?;\n                    history_file.flush()?;\n                    enforce_history_limit(&mut history_file, history_max_bytes)?;\n                    return Ok(());\n                }\n                Err(std::fs::TryLockError::WouldBlock) => {\n                    std::thread::sleep(RETRY_SLEEP);\n                }\n                Err(e) => return Err(e.into()),\n            }\n        }\n\n        Err(std::io::Error::new(\n            std::io::ErrorKind::WouldBlock,\n            \"could not acquire exclusive lock on history file after multiple attempts\",\n        ))\n    })\n    .await??;\n\n    Ok(())\n}\n\n/// Trim the history file to honor `max_bytes`, dropping the oldest lines while holding\n/// the write lock so the newest entry is always retained. When the file exceeds the\n/// hard cap, it rewrites the remaining tail to a soft cap to avoid trimming again\n/// immediately on the next write.\nfn enforce_history_limit(file: &mut File, max_bytes: Option<usize>) -> Result<()> {\n    let Some(max_bytes) = max_bytes else {\n        return Ok(());\n    };\n","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/message-history/src/lib.rs#L163-L199","documentation":"Error \"could not acquire exclusive lock on history file after multiple attempts\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/message-history/src/lib.rs:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}