Module watchdog

Module watchdog 

Source
Expand description

Watchdog timer for detecting stuck strands

Monitors strand execution time and triggers alerts when strands run too long without yielding. This helps detect infinite loops and runaway computation.

§Configuration (Environment Variables)

VariableDefaultDescription
SEQ_WATCHDOG_SECS0 (disabled)Threshold in seconds for “stuck” strand
SEQ_WATCHDOG_INTERVAL5Check frequency in seconds
SEQ_WATCHDOG_ACTIONwarnAction: warn (dump diagnostics) or exit (terminate)

§Example

# Enable watchdog with 30 second threshold, check every 10 seconds
SEQ_WATCHDOG_SECS=30 SEQ_WATCHDOG_INTERVAL=10 ./my-program

# Enable watchdog that exits on stuck strand
SEQ_WATCHDOG_SECS=60 SEQ_WATCHDOG_ACTION=exit ./my-program

§Design

The watchdog runs on a dedicated thread and periodically scans the strand registry. It compares each strand’s spawn time against the current time to detect strands that have been running longer than the threshold.

This piggybacks on the existing strand registry infrastructure, requiring no additional tracking overhead on the hot path.

§Feature Flag

This module requires the diagnostics feature (enabled by default). When disabled, the watchdog is not compiled.

Structs§

WatchdogConfig
Watchdog configuration

Enums§

WatchdogAction
Action to take when watchdog detects a stuck strand

Functions§

install_watchdog
Install the watchdog timer