{"record":{"id":"dd37359eac56604a","repo":"influxdata/influxdb","slug":"tempfile-i-o-0","errorCode":null,"errorMessage":"tempfile i/o: {0}","messagePattern":"tempfile i/o: (.+?)","errorType":"exception","errorClass":"HeapDumpError","httpStatus":null,"severity":"error","filePath":"core/jemalloc_stats/src/lib.rs","lineNumber":98,"sourceCode":"    target_os = \"android\",\n    target_os = \"dragonfly\",\n    target_env = \"musl\",\n)) {\n    \"_RJEM_MALLOC_CONF\"\n} else {\n    \"MALLOC_CONF\"\n};\n\n/// Errors returned by [`dump_heap_profile`].\n#[derive(Debug, thiserror::Error)]\npub enum HeapDumpError {\n    #[error(\"tempfile path was not valid C string (non-utf8 or interior NUL)\")]\n    BadTempPath,\n    #[error(\"heap profiling is disabled; restart with {MALLOC_CONF_ENV}=prof:true to enable\")]\n    ProfilingDisabled,\n    #[error(\"jemalloc prof.dump failed: {0}\")]\n    Jemalloc(#[from] tikv_jemalloc_ctl::Error),\n    #[error(\"tempfile i/o: {0}\")]\n    Io(#[from] std::io::Error),\n    #[error(\"blocking task join: {0}\")]\n    Join(#[from] tokio::task::JoinError),\n}\n\n/// Trigger a jemalloc heap profile dump and return a streaming reader for\n/// the resulting `heap_v2` bytes.\n///\n/// Requires jemalloc built with `--enable-prof` (i.e. `tikv-jemallocator`\n/// `profiling` feature) AND the binary started with `prof:true` in the\n/// platform-appropriate `MALLOC_CONF` env var (or via a baked-in\n/// `malloc_conf` static — see [`DEFAULT_MALLOC_CONF`]). When profiling is\n/// disabled at startup this returns [`HeapDumpError::ProfilingDisabled`].\n///\n/// The function handles all file machinery internally: it allocates a\n/// tempfile, runs jemalloc's synchronous `prof.dump`, unlinks the path, and\n/// hands back an open fd wrapped in a [`HeapProfileStream`]. The tempfile\n/// is unlinked before this call returns — POSIX semantics keep the inode","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/jemalloc_stats/src/lib.rs#L80-L116","documentation":"HeapDumpError::Io wraps a std::io::Error from tempfile creation/usage during dump_heap_profile. The heap profile is written into a temporary file before being streamed to the caller; any filesystem I/O failure along that path (create, open for reading, metadata) surfaces as this variant via #[from].","triggerScenarios":"Calling dump_heap_profile() when the temp directory is unwritable or missing, the filesystem is full, or the tempfile cannot be reopened after jemalloc writes the dump.","commonSituations":"Read-only or exhausted /tmp; restrictive TMPDIR in hardened containers; disk quota exceeded; tmpfs size limits on small Kubernetes pods.","solutions":["Fix temp-dir permissions/availability or point TMPDIR at a writable location and restart","Free disk space or raise the container tmpfs/disk limit","Retry the dump after addressing the I/O condition; the error's inner io::Error names the exact failing operation"],"exampleFix":"// before\nMALLOC_CONF=prof:true TMPDIR=/read-only ./myapp\n// after\nMALLOC_CONF=prof:true TMPDIR=/var/tmp ./myapp","handlingStrategy":"try-catch","validationCode":"fn tempdir_writable() -> bool {\n    tempfile::tempdir().map(|d| d.path().is_dir()).unwrap_or(false)\n}","typeGuard":null,"tryCatchPattern":"match dump_heap_profile().await {\n    Err(HeapDumpError::Io(e)) => { tracing::error!(%e, \"tempfile i/o\"); /* check disk/permissions */ }\n    other => other?,\n}","preventionTips":["Monitor temp-dir free space in containers","Point TMPDIR at a writable volume","Raise tmpfs size limits for pods using heap dumps"],"tags":["rust","io","tempfile","heap-profiling","filesystem"],"backgroundTag":"file-write-failed","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}