pub async fn daemon<F>(
lakehouse: Arc<LakehouseContext>,
view_registry: Arc<ViewRegistry>,
settings: Arc<SettingsSource>,
shutdown: F,
grace: Duration,
) -> Result<()>Expand description
Starts the maintenance daemon, which runs various scheduled tasks.
This function initializes and spawns several CronTasks for daily, hourly, minute,
and second-based maintenance operations, such as data materialization and cleanup,
plus a once-a-minute collector that samples the metadata Postgres’s pg_stat_*
views for self-observability. All runner loops react to shutdown: they stop
scheduling and drain in-flight tasks. A deadline arm forces return after grace
even if tasks haven’t drained.
§Arguments
lakehouse- The lakehouse context with shared metadata cache.view_registry- The shared registry (base views plus every DDL-defined global view); each view-carrying task resolves and sorts its own view list fromview_registry.current()fresh on every tick, so a view set created or dropped after the daemon started is picked up without a restart.settings- Source of the payload retention policy, read on every hourly pass, and of thedatafusion_config_maintenanceoverrides applied to every session the daemon builds.shutdown- Future that completes when the process should begin shutting down.grace- Maximum time to wait for in-flight tasks after the shutdown signal.