pola-rs/polars · error
failed to update file last accessed time
Error message
failed to update file last accessed time: {e} What it means
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.
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.
Example fix
// before let cache_dir = "/mnt/nfs-share/cache"; // exotic mount, may not support set_times // after let cache_dir = "/tmp/polars-cache"; // local filesystem with timestamp support
Defensive patterns
Strategy: try-catch
Validate before calling
let meta = std::fs::metadata(&path)?; let modified = meta.modified()?; // panics inside polars if None; check first assert!(modified.elapsed().is_ok(), "filesystem lacks timestamps");
Type guard
fn fs_supports_times(p: &std::path::Path) -> bool {
std::fs::metadata(p).ok()
.and_then(|m| m.modified().ok())
.is_some()
} Try / catch
// polars panics here; guard the environment before running
if !fs_supports_times(&file_path) {
// copy the file to a local FS or skip caching
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.
Related errors
- could not read
- failed to create spill file
- failed to open spill file
- Expecting to be able to downcast into bytes from read…
- failed to create file cache data directory: path =
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/59089ef69a153a62.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-io/src/file_cache/utils.rs:46
metadata
.modified()
.unwrap()
.duration_since(UNIX_EPOCH)
.unwrap()
.as_millis(),
)
.unwrap()
}
pub(super) fn update_last_accessed(file: &std::fs::File) {
let file_metadata = file.metadata().unwrap();
if let Err(e) = file.set_times(
std::fs::FileTimes::new()
.set_modified(file_metadata.modified().unwrap())
.set_accessed(std::time::SystemTime::now()),
) {
panic!("failed to update file last accessed time: {e}");
}
}
pub async fn init_entries_from_uri_list(
uri_list: impl ExactSizeIterator<Item = PlRefPath> + Send + 'static,
cloud_options: Option<&CloudOptions>,
) -> PolarsResult<Vec<Arc<FileCacheEntry>>> {
init_entries_from_uri_list_impl(Box::new(uri_list), cloud_options).await
}
async fn init_entries_from_uri_list_impl(
uri_list: Box<dyn ExactSizeIterator<Item = PlRefPath> + Send + 'static>,
cloud_options: Option<&CloudOptions>,
) -> PolarsResult<Vec<Arc<FileCacheEntry>>> {
#[allow(clippy::len_zero)]
if uri_list.len() == 0 {
return Ok(Default::default());
}View on GitHub (pinned to fe841f959e)