ides_march (ides v0.2.0)

View Source

Kill graph analysis and restart logic for ides.

Summary

Functions

Return the PIDs of siblings that would be killed or restarted if TargetPid dies.

Return all PIDs that could cause TargetPid to be killed.

Return the kill graph with each entry tagged by its kill mechanism

Return link information for the given process.

Return monitor information for the given process.

Return whether a terminated child Pid would be restarted by its supervisor.

Types

exit_reason()

-type exit_reason() :: normal | abnormal.

Functions

affected_siblings(TargetPid)

-spec affected_siblings(TargetPid :: pid()) -> {ok, [pid()]} | {error, term()}.

Return the PIDs of siblings that would be killed or restarted if TargetPid dies.

Depends on the parent supervisor's strategy:

  • one_for_one: TargetPid only
  • one_for_all: all siblings
  • rest_for_one: TargetPid and all siblings after it
  • simple_one_for_one: TargetPid only

kill_graph(TargetPid)

-spec kill_graph(TargetPid :: pid()) -> {ok, [pid()]} | {error, term()}.

Return all PIDs that could cause TargetPid to be killed.

This is the set of ancestors unioned with siblings that trigger cascade restarts under the parent supervisor's strategy:

  • one_for_one / simple_one_for_one: only ancestors (no sibling killers)
  • one_for_all: all siblings are killers
  • rest_for_one: siblings at positions before the target are killers

kill_graph_detail(TargetPid)

-spec kill_graph_detail(TargetPid :: pid()) -> {ok, [ides_family:kill_source()]} | {error, term()}.

Return the kill graph with each entry tagged by its kill mechanism:

  • ancestor — supervisor ancestor
  • sibling — sibling via supervisor strategy
  • link — linked process (relevant if target doesn't trap exits)
  • monitor — monitored process (relevant if target doesn't handle DOWN)

monitor_info(Pid)

-spec monitor_info(Pid :: pid()) -> {ok, ides_family:monitor_info()} | {error, term()}.

Return monitor information for the given process.

Reports which processes Pid is monitoring and which processes are monitoring Pid. Monitored processes are potential killers if Pid doesn't handle DOWN messages.

should_restart(Pid, Reason)

-spec should_restart(Pid :: pid(), Reason :: exit_reason()) -> boolean().

Return whether a terminated child Pid would be restarted by its supervisor.

Rules:

  • permanent: always restarted
  • transient: restarted only on abnormal exit
  • temporary: never restarted