prefect.server.services.db_vacuum
The database vacuum service. Two perpetual services schedule cleanup tasks
independently, gated by the enabled set in
PREFECT_SERVER_SERVICES_DB_VACUUM_ENABLED (default ["events"]):
-
schedule_vacuum_tasks — Cleans up old flow runs and orphaned resources
(logs, artifacts, artifact collections). Enabled when
"flow_runs"is in the enabled set. -
schedule_event_vacuum_tasks — Cleans up old events, including any
event types with per-type retention overrides. Enabled when
"events"is in the enabled set andevent_persister.enabledis true (the default), so that operators who disabled event processing are not surprised on upgrade. Runs in all server modes, including ephemeral.
PREFECT_SERVER_SERVICES_DB_VACUUM_EVENT_RETENTION_OVERRIDES. Event types
not listed fall back to server.events.retention_period.
Each task runs independently with its own error isolation and
docket-managed retries. Deterministic keys prevent duplicate tasks from
accumulating if a cycle overlaps with in-progress work.
Functions
schedule_vacuum_tasks
schedule_event_vacuum_tasks
"events" is in the default enabled set).
Automatically disabled when the event persister service is disabled
(PREFECT_SERVER_SERVICES_EVENT_PERSISTER_ENABLED=false) so that
operators who opted out of event processing are not surprised by
trimming on upgrade.
vacuum_orphaned_logs
vacuum_orphaned_artifacts
vacuum_stale_artifact_collections
vacuum_old_flow_runs
vacuum_events_with_retention_overrides
event_retention_overrides and deletes
events (and their resources) that are older than the configured retention
for that type, capped by the global events retention period.