Skip to main content

Module stale_sweep

Module stale_sweep 

Source
Expand description

The timer that runs didbot_pds::Provisioner::sweep_stale_bounded.

A process that stops between storing an account and activating it — a SIGKILL, a lost machine, an OOM kill — leaves a row behind that nothing else comes back for. The sweep removes that row, whatever the account’s kind, once it is older than DEFAULT_UNFINISHED_AGE, and its hostname answers 404 from then on the way every name no account holds does. It also finishes an erasure a crash left half done. Every other account stays, whatever its age.

§Why a timer rather than a startup pass

Both, really — the first tick fires immediately, so a restart reaps without waiting an interval, and the ticks after it cover a process that stays up for weeks. A startup-only pass would leave a long-lived server accumulating stale rows until somebody restarted it, which is the opposite of what a deployment that must not be restarted wants.

§What one tick costs

Each deletion takes the write lock every request path takes. SweepSchedule::limit is what keeps a deployment that has accumulated a backlog from holding it for one tick of thousands of deletions back to back; what a tick leaves behind is taken by the next one.

Structs§

StaleSweeper
A running sweep, stopped by StaleSweeper::stop or by dropping it.
SweepSchedule
When the sweep runs and how much it takes.

Constants§

DEFAULT_SWEEP_INTERVAL
How often the sweep runs, absent configuration.
DEFAULT_SWEEP_LIMIT
How many rows one tick takes, absent configuration.
DEFAULT_UNFINISHED_AGE
How old a row that never became an account gets before the sweep removes it, absent configuration.

Functions§

sweep_once
One tick: sweep, say what it took.