{"record":{"id":"15cd68ae61403d8c","repo":"tinyhumansai/openhuman","slug":"acquire-workspace-write-flock-e","errorCode":null,"errorMessage":"acquire workspace write flock: {e}","messagePattern":"acquire workspace write flock: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/openhuman/tools/impl/filesystem/update_memory_md.rs","lineNumber":89,"sourceCode":"                return Err(anyhow::anyhow!(\n                    \"workspace lock file {lock_path:?} is a symlink; refusing to follow it\"\n                ));\n            }\n        }\n        let mut opts = std::fs::OpenOptions::new();\n        opts.create(true).write(true).truncate(false);\n        #[cfg(unix)]\n        {\n            // O_NOFOLLOW closes the TOCTOU window: if a symlink is swapped in\n            // after the check above, the open fails (ELOOP) rather than follows.\n            use std::os::unix::fs::OpenOptionsExt;\n            opts.custom_flags(libc::O_NOFOLLOW);\n        }\n        let file = opts\n            .open(&lock_path)\n            .map_err(|e| anyhow::anyhow!(\"open workspace lock file {lock_path:?}: {e}\"))?;\n        file.lock_exclusive()\n            .map_err(|e| anyhow::anyhow!(\"acquire workspace write flock: {e}\"))?;\n        Ok::<std::fs::File, anyhow::Error>(file)\n    })\n    .await\n    .map_err(|e| anyhow::anyhow!(\"workspace lock task join failed: {e}\"))?\n}\n\n/// Atomically replace `path`'s contents with `content`.\n///\n/// Writes to a sibling temp file in the same directory (so the rename stays on\n/// one filesystem and is atomic) and `rename`s it over the target. A crash\n/// mid-write leaves either the old file or the complete new file — never a\n/// half-written truncation. Callers MUST hold the per-workspace write lock so\n/// the read-modify-write is serialized end-to-end.\nasync fn atomic_write(path: &Path, file: &str, content: &str) -> anyhow::Result<()> {\n    let dir = path\n        .parent()\n        .ok_or_else(|| anyhow::anyhow!(\"target path has no parent directory\"))?;\n    let seq = TEMP_FILE_SEQ.fetch_add(1, Ordering::Relaxed);","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/tools/impl/filesystem/update_memory_md.rs#L71-L107","documentation":"Taking the exclusive flock on .memory-write.lock failed with the OS error {e}. The file opened, but lock_exclusive refused — typically because another process holds the lock and flock errored (e.g. on NFS or a filesystem without flock support), not merely because it was busy (flock blocks rather than errors in that case).","triggerScenarios":"Thrown at src/openhuman/tools/impl/filesystem/update_memory_md.rs:89 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Read {e}: unsupported-filesystem errors mean the workspace must live on a local filesystem","Ensure no stuck process holds the lock (check lsof/fuser)","Retry after clearing the conflicting holder"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}