influxdata/influxdb · error · HeapDumpError
tempfile i/o
Error message
tempfile i/o: {0} What it means
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].
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
Example fix
// before MALLOC_CONF=prof:true TMPDIR=/read-only ./myapp // after MALLOC_CONF=prof:true TMPDIR=/var/tmp ./myapp
Defensive patterns
Strategy: try-catch
Validate before calling
fn tempdir_writable() -> bool {
tempfile::tempdir().map(|d| d.path().is_dir()).unwrap_or(false)
} Try / catch
match dump_heap_profile().await {
Err(HeapDumpError::Io(e)) => { tracing::error!(%e, "tempfile i/o"); /* check disk/permissions */ }
other => other?,
} Prevention
- Monitor temp-dir free space in containers
- Point TMPDIR at a writable volume
- Raise tmpfs size limits for pods using heap dumps
When it happens
Trigger: 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.
Common situations: Read-only or exhausted /tmp; restrictive TMPDIR in hardened containers; disk quota exceeded; tmpfs size limits on small Kubernetes pods.
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
- error writing wal file
- io error
- IO error
- tempfile path was not valid C string (non-utf8 or interior…
- blocking task join
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/dd37359eac56604a.
Report an issue: GitHub.
Appendix: source
Thrown at core/jemalloc_stats/src/lib.rs:98
target_os = "android",
target_os = "dragonfly",
target_env = "musl",
)) {
"_RJEM_MALLOC_CONF"
} else {
"MALLOC_CONF"
};
/// Errors returned by [`dump_heap_profile`].
#[derive(Debug, thiserror::Error)]
pub enum HeapDumpError {
#[error("tempfile path was not valid C string (non-utf8 or interior NUL)")]
BadTempPath,
#[error("heap profiling is disabled; restart with {MALLOC_CONF_ENV}=prof:true to enable")]
ProfilingDisabled,
#[error("jemalloc prof.dump failed: {0}")]
Jemalloc(#[from] tikv_jemalloc_ctl::Error),
#[error("tempfile i/o: {0}")]
Io(#[from] std::io::Error),
#[error("blocking task join: {0}")]
Join(#[from] tokio::task::JoinError),
}
/// Trigger a jemalloc heap profile dump and return a streaming reader for
/// the resulting `heap_v2` bytes.
///
/// Requires jemalloc built with `--enable-prof` (i.e. `tikv-jemallocator`
/// `profiling` feature) AND the binary started with `prof:true` in the
/// platform-appropriate `MALLOC_CONF` env var (or via a baked-in
/// `malloc_conf` static — see [`DEFAULT_MALLOC_CONF`]). When profiling is
/// disabled at startup this returns [`HeapDumpError::ProfilingDisabled`].
///
/// The function handles all file machinery internally: it allocates a
/// tempfile, runs jemalloc's synchronous `prof.dump`, unlinks the path, and
/// hands back an open fd wrapped in a [`HeapProfileStream`]. The tempfile
/// is unlinked before this call returns — POSIX semantics keep the inodeView on GitHub (pinned to 06200ef96b)