View Source ProcessHub.Worker.Janitor (ProcessHub v0.8.0)

Purges expired TTL entries from the hub's storage and registry.

An expired registry row is one of two kinds:

  • a pending forward: a start forwarded to another node that never registered. It is removed and logged.
  • a churn placeholder: the row a move, a duplicate resolution or a node-down cleanup leaves when it stops the child's last registered copy, kept 30 seconds for the replacement to register. When nothing registered, the child runs nowhere although nobody asked to stop it (a user stop removes the row instead of leaving a placeholder), so it is re-placed through the distribution strategy. Only the node the strategy names first submits the start, and only while the hub is not partitioned, every node answers that the child is not running, and the row read again just before the start is still an unbound placeholder. Attempts are bounded and backed off, each one logged, a deferred one too; after the last, the row is removed and logged. A durable child's placeholder is removed at once: the orphan reconcile restarts it while it is declared.

Summary

Functions

Returns a specification to start this module under a supervisor.

Purges expired TTL cache entries from the given storage table.

Handles the expired TTL rows of the registry table (see the moduledoc).

Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

purge_expired_cache(misc_storage)

View Source
@spec purge_expired_cache(:ets.tid()) :: :ok

Purges expired TTL cache entries from the given storage table.

Removes every 3-tuple entry {key, value, expire_timestamp} whose timestamp has passed, in one atomic delete, so an entry re-written with a fresh TTL meanwhile is kept.

Link to this function

purge_pending_registry(hub_id)

View Source
@spec purge_pending_registry(ProcessHub.hub_id()) :: :ok

Handles the expired TTL rows of the registry table (see the moduledoc).

Only rows whose key in the hub's expiry index has fallen due are read, each by its child id, so the cost follows the rows due, not the registry's size.