{"record":{"id":"59089ef69a153a62","repo":"pola-rs/polars","slug":"failed-to-update-file-last-accessed-time-e","errorCode":null,"errorMessage":"failed to update file last accessed time: {e}","messagePattern":"failed to update file last accessed time: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-io/src/file_cache/utils.rs","lineNumber":46,"sourceCode":"        metadata\n            .modified()\n            .unwrap()\n            .duration_since(UNIX_EPOCH)\n            .unwrap()\n            .as_millis(),\n    )\n    .unwrap()\n}\n\npub(super) fn update_last_accessed(file: &std::fs::File) {\n    let file_metadata = file.metadata().unwrap();\n\n    if let Err(e) = file.set_times(\n        std::fs::FileTimes::new()\n            .set_modified(file_metadata.modified().unwrap())\n            .set_accessed(std::time::SystemTime::now()),\n    ) {\n        panic!(\"failed to update file last accessed time: {e}\");\n    }\n}\n\npub async fn init_entries_from_uri_list(\n    uri_list: impl ExactSizeIterator<Item = PlRefPath> + Send + 'static,\n    cloud_options: Option<&CloudOptions>,\n) -> PolarsResult<Vec<Arc<FileCacheEntry>>> {\n    init_entries_from_uri_list_impl(Box::new(uri_list), cloud_options).await\n}\n\nasync fn init_entries_from_uri_list_impl(\n    uri_list: Box<dyn ExactSizeIterator<Item = PlRefPath> + Send + 'static>,\n    cloud_options: Option<&CloudOptions>,\n) -> PolarsResult<Vec<Arc<FileCacheEntry>>> {\n    #[allow(clippy::len_zero)]\n    if uri_list.len() == 0 {\n        return Ok(Default::default());\n    }","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-io/src/file_cache/utils.rs#L28-L64","documentation":"This panic fires when the OS-level call to update a cached file's timestamps (via file.set_times) fails while Polars updates the last-accessed time of a file in its cache. The library treats cache metadata upkeep as a hard invariant, so failure is a panic rather than a recoverable error. It typically indicates an OS/filesystem-level problem with the already-open file handle.","triggerScenarios":"Calling try_open_assume_latest, try_open_check_latest, or finish_open in the file cache when the underlying std::fs::File rejects set_times(); also triggered if file_metadata.modified() returns None and unwrap panics on filesystems without modification times.","commonSituations":"Files on filesystems that don't support access/modified timestamps (some network mounts, tmpfs variants, FUSE filesystems); permission-restricted files; Windows files locked by another process.","solutions":["Verify the file resides on a filesystem that supports access-time updates (avoid unusual network/FUSE mounts for the cache path).","Check file permissions and that no other process holds the file open in a mode blocking timestamp updates.","Point POLARS_TEMP_DIR / cache directory at a local POSIX filesystem.","If it persists, report to polars with OS and filesystem details, as set_times failing on a valid handle is environmental."],"exampleFix":"// before\nlet cache_dir = \"/mnt/nfs-share/cache\"; // exotic mount, may not support set_times\n// after\nlet cache_dir = \"/tmp/polars-cache\"; // local filesystem with timestamp support","handlingStrategy":"try-catch","validationCode":"let meta = std::fs::metadata(&path)?;\nlet modified = meta.modified()?; // panics inside polars if None; check first\nassert!(modified.elapsed().is_ok(), \"filesystem lacks timestamps\");","typeGuard":"fn fs_supports_times(p: &std::path::Path) -> bool {\n    std::fs::metadata(p).ok()\n        .and_then(|m| m.modified().ok())\n        .is_some()\n}","tryCatchPattern":"// polars panics here; guard the environment before running\nif !fs_supports_times(&file_path) {\n    // copy the file to a local FS or skip caching\n}","preventionTips":["Keep the polars file cache on a local POSIX filesystem, not FUSE/network mounts","Confirm filesystems in use support access/modified times before enabling file caching","Avoid sharing cache directories across OSes with different timestamp semantics"],"tags":["filesystem","file-cache","panic","io"],"backgroundTag":"file-write-failed","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}