{"record":{"id":"8acc5838fd691d2f","repo":"pola-rs/polars","slug":"failed-to-create-spill-file-e","errorCode":null,"errorMessage":"failed to create spill file '{}': {e}","messagePattern":"failed to create spill file '(.+?)': (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/polars-ooc/src/spill_frame.rs","lineNumber":62,"sourceCode":"        let file = ASYNC\n            .spawn(async move {\n                let size = buf.len() as u64;\n                let spill_file = SpillFile::new(&context_id, \"ipc\", size);\n                if BYTES_SPILLED_TO_DISK.fetch_add(size).saturating_add(size)\n                    > polars_config::config().ooc_disk_budget_bytes()\n                {\n                    spill_file.creation_aborted();\n                    polars_error::abort::polars_abort_ooc_out_of_disk();\n                }\n                match tokio::fs::write(spill_file.path(), buf).await {\n                    Ok(()) => spill_file,\n                    Err(e) => {\n                        let msg = format!(\n                            \"failed to create spill file '{}': {e}\",\n                            spill_file.path().display()\n                        );\n                        spill_file.creation_aborted();\n                        panic!(\"{msg}\")\n                    },\n                }\n            })\n            .await\n            .unwrap();\n        Arc::new(file)\n    }\n\n    async fn unspill(location: &Self::Spilled) -> Self {\n        let path = location.path().to_owned();\n        ASYNC\n            .spawn_blocking(move || {\n                let file = std::fs::File::open(&path).unwrap_or_else(|e| {\n                    panic!(\"failed to open spill file {:?}: {e}\", path.display())\n                });\n                IpcStreamReader::new(file).finish().unwrap_or_else(|e| {\n                    panic!(\"failed to read spill file {:?}: {e}\", path.display())\n                })","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-ooc/src/spill_frame.rs#L44-L80","documentation":"Panics in SpilledFrame::spill when creating the temporary spill file on disk fails. Polars OOC (out-of-core) spills DataFrame data to a temp file when memory is tight; if the OS refuses to create the file (permissions, no space, missing temp dir), the async task panics instead of returning a Result.","triggerScenarios":"Calling spill when tempfile::NamedTempFile creation returns Err(e): disk full, read-only filesystem, missing TMPDIR, or permission denied on the temp directory.","commonSituations":"Disk quota exceeded during large sorts/joins with limited RAM; containers with tiny or read-only /tmp; TMPDIR pointing to a non-existent path; running with restrictive SELinux/AppArmor profiles.","solutions":["Free disk space or raise the quota on the volume holding the temp directory","Set TMPDIR (or POLARS_TEMP_DIR if honored) to a writable directory with enough space","Fix directory permissions for the user running the Polars process","Reduce memory pressure / batch size so spilling is not needed"],"exampleFix":"// before\nlet spill_file = NamedTempFile::new_in(tmp_dir)?; // panics inside on failure\n// after\nlet spill_file = match NamedTempFile::new_in(writable_dir) {\n    Ok(f) => f,\n    Err(e) => return Err(PolarsError::IO(format!(\"spill file create failed: {e}\").into())),\n};","handlingStrategy":"validation","validationCode":"// Rust: check temp dir writability + free space before spilling\nlet tmp = std::env::temp_dir();\nlet probe = tmp.join(\".polars_spill_probe\");\nstd::fs::write(&probe, b\"x\").map_err(|e| e.to_string())?;\nstd::fs::remove_file(&probe).ok();\nfs2::available_space(&tmp)?; // ensure > expected spill size","typeGuard":null,"tryCatchPattern":"std::panic::catch_unwind(|| run_query()); // panic crosses spawn_blocking via .await.unwrap()","preventionTips":["Monitor free space on the temp volume before large queries","Point TMPDIR to dedicated writable scratch storage","Right-size memory to reduce spilling"],"tags":["io","filesystem","out-of-core","spill","panic"],"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"}