openai/codex · error · std::io::Error
WouldBlock
WouldBlock
Error message
could not acquire shared history lock after multiple attempts
What it means
Error "could not acquire shared history lock after multiple attempts" thrown in openai/codex.
Source
Thrown at codex-rs/message-history/src/batch.rs:131
cursor: HistoryBatchCursor,
config: &HistoryConfig,
) -> std::io::Result<HistoryBatch> {
let path = history_filepath(config);
let mut file = OpenOptions::new().read(true).open(path)?;
let current_log_id = log_identity(&file.metadata()?).unwrap_or(0);
if log_id != 0 && current_log_id != log_id {
return Ok(HistoryBatch::default());
}
for _ in 0..MAX_RETRIES {
match file.try_lock_shared() {
Ok(()) => return scan_batch(&mut file, cursor, config),
Err(std::fs::TryLockError::WouldBlock) => std::thread::sleep(RETRY_SLEEP),
Err(error) => return Err(error.into()),
}
}
Err(std::io::Error::new(
std::io::ErrorKind::WouldBlock,
"could not acquire shared history lock after multiple attempts",
))
}
/// Selects the anchored backward scan only for an unchanged, uncapped history file.
///
/// Capped histories always use the forward scan because trimming rewrites them in place and a
/// same-size rewrite may not be distinguishable from metadata on filesystems with coarse
/// modification times. Falling back preserves absolute row semantics at the cost of rescanning
/// that request from the beginning.
fn scan_batch(
file: &mut File,
cursor: HistoryBatchCursor,
config: &HistoryConfig,
) -> std::io::Result<HistoryBatch> {
let metadata = file.metadata()?;
let revision = HistoryFileRevision {View on GitHub (pinned to 339751715c)
When it happens
Trigger: Thrown at codex-rs/message-history/src/batch.rs:131 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of openai/codex@339751715c (2026-08-25).
Data as JSON: /api/errors/a8262fa508499b7d.
Report an issue: GitHub.