[Task Manager] Opt-in event loop watchdog to diagnose blocking tasks
Author: mikecoteCreated Sep 21, 2026Updated Oct 1, 2026
LabelsFeature:Task ManagerTeam:ResponseOps
Summary
Add an opt-in, disabled-by-default Task Manager diagnostic that detects when the Kibana main event loop blocks longer than a threshold and logs a report with (1) the task(s) in flight when the block started and (2) a CPU-profile summary of what was running.
Goal is closer to answer "did the loop block, and what was probably running?" so operators can find the offender.
Proposed shape
- Config under
xpack.task_manager.event_loop_watchdog(enabled: falseby default; threshold / heartbeat / report tuning) - Starts only on nodes that run background tasks
- Task runner announces run start/end so reports can name in-flight suspects
- Live "still blocked" notices go to stderr so a wedged loop still surfaces something (to verify on ECH / Serverless)
Prototype PR: #292147
Known limitations (from prototype testing)
- JS bytecode blocks: CPU profile top frames are accurate; in-flight task suspects can race (task may leave the registry before the suspect snapshot if
notifyTaskRunEndfires beforeProfiler.stopcompletes). - Native syscall / I/O waits (e.g. sync
exec*): may produce no useful profile (no V8 safepoint for profiler interrupts). - Native CPU-bound blocks (e.g. sync crypto): can misattribute to unrelated JS that runs after the block unless we classify confidence (CPU busy delta + first-sample timing vs. block window).
Some workarounds sketched in #292147: classify reports with process.cpuUsage() delta + first-sample timing so native/syscall cases emit an explicit low-confidence verdict instead of silence or wrong blame.
Source: elastic/kibana