{"record":{"id":"fb14bc0ebd1de5fc","repo":"influxdata/influxdb","slug":"jemalloc-prof-dump-failed-0","errorCode":null,"errorMessage":"jemalloc prof.dump failed: {0}","messagePattern":"jemalloc prof\\.dump failed: (.+?)","errorType":"exception","errorClass":"HeapDumpError","httpStatus":null,"severity":"error","filePath":"core/jemalloc_stats/src/lib.rs","lineNumber":96,"sourceCode":"    target_os = \"macos\",\n    target_os = \"ios\",\n    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","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/jemalloc_stats/src/lib.rs#L78-L114","documentation":"HeapDumpError::Jemalloc wraps a tikv_jemalloc_ctl::Error raised when the prof.dump mallctl call fails during dump_heap_profile. The tempfile was created successfully, but asking jemalloc to write the heap profile into it returned an error from the allocator control API. The original control error is preserved via #[from] for diagnosis.","triggerScenarios":"Calling dump_heap_profile() when the underlying jemalloc prof.dump mallctl rejects the write: profiling option mismatches at runtime, dump target permission issues inside the temp dir, or a jemalloc built without the profiling feature despite the env flag.","commonSituations":"A jemalloc build (e.g. system jemalloc compiled without --enable-prof) that ignores prof:true; disk full or permission problems in the temp directory; concurrent dumps racing on the same target.","solutions":["Inspect the wrapped tikv_jemalloc_ctl::Error via Display/source to see the mallctl failure","Confirm the linked jemalloc was built with profiling support (--enable-prof) and that MALLOC_CONF=prof:true was actually applied","Check temp-dir permissions and free space; retry the dump once conditions are fixed"],"exampleFix":"// before\nlet stream = dump_heap_profile().await?; // opaque failure\n// after\nmatch dump_heap_profile().await {\n    Ok(s) => /* ... */,\n    Err(HeapDumpError::Jemalloc(e)) => tracing::error!(%e, \"jemalloc mallctl failed\"),\n    Err(e) => return Err(e.into()),\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"match dump_heap_profile().await {\n    Err(HeapDumpError::Jemalloc(e)) => { tracing::error!(%e, \"prof.dump failed\"); /* inspect source chain */ }\n    other => other?,\n}","preventionTips":["Verify the linked jemalloc is built with --enable-prof","Keep temp dirs writable with free space","Avoid racing concurrent heap dumps"],"tags":["rust","jemalloc","heap-profiling","mallctl"],"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"}