{"record":{"id":"a8262fa508499b7d","repo":"openai/codex","slug":"wouldblock","errorCode":"WouldBlock","errorMessage":"could not acquire shared history lock after multiple attempts","messagePattern":"could not acquire shared history lock after multiple attempts","errorType":"error_code","errorClass":"std::io::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/message-history/src/batch.rs","lineNumber":131,"sourceCode":"    cursor: HistoryBatchCursor,\n    config: &HistoryConfig,\n) -> std::io::Result<HistoryBatch> {\n    let path = history_filepath(config);\n    let mut file = OpenOptions::new().read(true).open(path)?;\n    let current_log_id = log_identity(&file.metadata()?).unwrap_or(0);\n    if log_id != 0 && current_log_id != log_id {\n        return Ok(HistoryBatch::default());\n    }\n\n    for _ in 0..MAX_RETRIES {\n        match file.try_lock_shared() {\n            Ok(()) => return scan_batch(&mut file, cursor, config),\n            Err(std::fs::TryLockError::WouldBlock) => std::thread::sleep(RETRY_SLEEP),\n            Err(error) => return Err(error.into()),\n        }\n    }\n\n    Err(std::io::Error::new(\n        std::io::ErrorKind::WouldBlock,\n        \"could not acquire shared history lock after multiple attempts\",\n    ))\n}\n\n/// Selects the anchored backward scan only for an unchanged, uncapped history file.\n///\n/// Capped histories always use the forward scan because trimming rewrites them in place and a\n/// same-size rewrite may not be distinguishable from metadata on filesystems with coarse\n/// modification times. Falling back preserves absolute row semantics at the cost of rescanning\n/// that request from the beginning.\nfn scan_batch(\n    file: &mut File,\n    cursor: HistoryBatchCursor,\n    config: &HistoryConfig,\n) -> std::io::Result<HistoryBatch> {\n    let metadata = file.metadata()?;\n    let revision = HistoryFileRevision {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/message-history/src/batch.rs#L113-L149","documentation":"Error \"could not acquire shared history lock after multiple attempts\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/message-history/src/batch.rs:131 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"}