Celery Schedule - Daily Task Execution¶
This document outlines the scheduled tasks in the DAS system organized by hour of the day.
Hour-by-Hour Schedule¶
12:00 AM (00:00)¶
set_alert_counter_for_all_users - Resets alert counter for all users
Task:
activity.tasks.reset_alert_counter_for_all_usersSchedule: Daily at midnight
2:00 AM¶
download-features-from-wfs - Downloads features from Web Feature Service
Task:
mapping.tasks.automate_download_features_from_wfsSchedule: Daily at 2:00 AM
3:00 AM¶
reconcile-observation-segments - Daily safety net that detects and rebuilds
ObservationSegmentgaps in the recent window for each tenant. Walks every source with activity in the lastOBSERVATION_SEGMENT_RECONCILE_HOURShours; runsrecompute_observation_segments_for_source_range(idempotent viaselect_for_update+IntegrityErrorfallback) when the segment count diverges fromcount(valid_obs) - 1. Closes the gap left by paths that bypasspost_save(notably bulk updates onexclusion_flags).Task:
observations.tasks.reconcile_observation_segments_taskSchedule: Daily at 3:00 AM (tenant-local, ahead of the 4:00 AM cleanup run)
Queue:
maintenanceOptions:
expires=20hso stale per-tenant messages drop before the next run if workers fall behind.
4:00 AM¶
routine-delete-observational-data - Maintains observation data (cleanup)
Task:
observations.tasks.maintain_observation_dataSchedule: Daily at 4:00 AM
6:00 AM¶
reports - Generates subject/source reports
Task:
reports.tasks.subjectsource_reportSchedule: Daily at 6:00 AM
Every Hour¶
check-sources-threshold - Checks sources threshold
Task:
reports.tasks.run_check_sources_thresholdSchedule: Every hour
refresh_tenants_cache - Refreshes tenants cache
Task:
das_server.tasks.refresh_tenants_cacheSchedule: Every hour
Every 15 Minutes¶
firms-plugins - Schedules FIRMS plugins
Task:
tracking.tasks.schedule_firms_pluginsSchedule: Every 15 minutes
poll_news_gcs_bucket - Polls news GCS bucket
Task:
observations.tasks.poll_news_gcs_bucketSchedule: Every 15 minutes
Every 10 Minutes¶
sweep-orphan-socketio-queues - Deletes orphan
python-socketio.*queue keys left in the realtime broker Redis when a socketio consumer terminates abnormally. Removes keys idle for more than 24h and the matching entry in the_kombu.binding.socketioregistry.Task:
rt_api.tasks.sweep_orphan_socketio_queuesSchedule: Every 10 minutes
Queue:
maintenance
Every 5 Minutes¶
plugins - Runs tracking plugins
Task:
tracking.tasks.run_pluginsSchedule: Every 5 minutes
auto-resolve - Automatically updates event state
Task:
activity.tasks.automatically_update_event_stateSchedule: Every 5 minutes
Every 30 Minutes¶
observation-lag-report - Reports on observation lag delays
Task:
reports.tasks.alert_lag_delaySchedule: Every 30 minutes
Every Minute¶
periodically_maintain_patrol_state - Maintains patrol state
Task:
activity.tasks.periodically_maintain_patrol_stateSchedule: Every minute
Every 60 Seconds¶
beat-pulse - Celery beat pulse routine
Task:
das_server.tasks.celerybeat_pulseSchedule: Every 60 seconds
Every 15 Seconds¶
service-status - Broadcasts service status
Task:
rt_api.tasks.broadcast_service_statusSchedule: Every 15 seconds
Every 60 Seconds¶
redis-status - Checks Redis queues
Task:
rt_api.tasks.check_redis_queuesSchedule: Every 60 seconds
Every 12 Hours¶
subject-status-maintenance - Maintains subject status for all subjects
Task:
observations.tasks.maintain_subjectstatus_allSchedule: Every 12 hours
Weekly (Sunday at 11:00 PM)¶
postgresql_partman_maintain_observation_partitions - Creates the missing monthly partitions of each partman-managed observations table (
observations_observation,observations_observationsegment) in turn, for the current UTC month throughpremakemonths ahead, withpartman.create_partition_time. A failure on one table or month is logged and does not stop the others.Task:
observations.tasks.maintain_observation_partitionsSchedule: Every Sunday at 11:00 PM (finishes before the Monday midnight check)
Runs once per database, not per tenant: every tenant’s rows share these tables and pg_partman config is per table.
Applies no retention. The
'3 years'retention inpartman.part_configforobservations_observationsegment(set by migrationobservations/0200) is not enforced by this job and would need its own explicit job.
Weekly (Monday at 12:00 AM)¶
postgresql_partman_check_observation_partitions - Runs the partition table check (premake >= 3, and a partition present for every month from the current UTC month through
premake - 1months ahead) onobservations_observationandobservations_observationsegment. A missing month whose rows are already in the default partition also gets thefix_partition_by_monthhint described below.Task:
observations.tasks.check_observation_partitionsSchedule: Every Monday at midnight
Queue Priorities¶
The system uses different queues to manage task priorities:
realtime_p1: High-priority real-time tasks
realtime_p2: Medium-priority real-time tasks
realtime_p3: Lower-priority real-time tasks
maintenance: System maintenance tasks
analyzers: Analysis and processing tasks
Notes¶
All times are based on the system’s configured timezone (
settings.TIME_ZONE)Tasks with
timedeltaschedules run continuously at the specified intervalsTasks with
crontabschedules run at specific times on specific daysThe
PLUGINS_INTERVALis set to 5 minutes (300 seconds) for plugin executionHigh-frequency tasks like service status and Redis checks ensure system health monitoring
Partition maintenance:
maintain_observation_partitionsnever callspartman.run_maintenance()orrun_maintenance_proc(). In pg_partman 5,run_maintenanceanchors on the newest child partition that holds rows and ignoresnow()(withinfinite_time_partitions = false) and the default partition. One far-future row in a child therefore makes it create every month up to that date pluspremakein a single run, and rows landing in the default partition freeze it. Instead, for each table the job readscontrol,premakeandpartition_intervalfrompartman.part_config. It skips the table, with anER Partman:error, if the table is not registered or the interval is not exactly one month. Its target window runs from the current UTC month throughpremakemonths ahead, which covers every month the Monday check expects. The check deliberately expects one month fewer than the job creates: it runs an hour after the job, so when the 1st is a Monday it runs in the next month, and expectingpremake + 1months would then demand a month the job had no reason to create yet, and the months missing from the existing partition boundaries are the ones to create. Each missing month not blocked by default-partition rows (see below) is created withpartman.create_partition_timeand an explicit UTC month start ('2026-11-01 00:00:00+00'), one month per transaction withlock_timeout = 5s,statement_timeout = 60sandTimeZone = UTCset locally. One month failing does not undo or stop the others. A monthly maintenance task with no timeouts was removed in December 2024 after it brought down the API (ERA-10622): attaching a partition takes an ACCESS EXCLUSIVE lock on the default partition and scans it, so a lock request stuck behind a long-running query queues all later queries on the table. A month that hits a timeout logsER Partman: [<table>] Could not create the YYYY-MM partition.and is retried the following Sunday; withpremake = 5, weekly runs leave months of slack. To run the same job on demand, usepython manage.py partman_maintain_observation_partitions.--table <name>limits it to one table, and--dry-runreports each table’s control, premake and interval, the target window, the months already present, the months it would create, and the blocked months with fix hints, without writing anything. It prints a per-table outcome (created, already present, blocked, failed) and exits non-zero if a table was skipped or any month was blocked or failed. Do not usemanage.py partman_run_maintenance_procfor this: it runsrun_maintenanceon every table inpartman.part_config, with the anchoring problem above, and applies their retention.Partitions blocked by the default partition: PostgreSQL refuses to attach a monthly partition while rows in its range sit in the default partition (
updated partition constraint for default partition ... would be violated by some row). Before creating partitions, and when the weekly check finds a missing month, the job probes<table>_defaultfor each unpartitioned month in the window (one boundedEXISTSper month, under the same timeouts, on thecontrolcolumn read frompartman.part_config). Blocked months are skipped, and later months are still created; a month whose rows reach the default partition between the probe and its creation is reported the same way. The job only reports; it never moves data. For each blocked month it logs one error with the command an operator should run, for example:ER Partman: [public.observations_observationsegment] Cannot create the 2026-11 partition: rows in that range are in the default partition. Preview with `python manage.py fix_partition_by_month -t observations_observationsegment --partition-column start_recorded_at -y 2026 -m 11 --dry-run`, then run `python manage.py fix_partition_by_month -t observations_observationsegment --partition-column start_recorded_at -y 2026 -m 11`.
Signal-driven (not scheduled):
observations.tasks.update_observation_segments_batch_taskis enqueued from theObservationpost_savesignal — buffered per (thread, db_alias) and flushed on commit, chunked byOBSERVATION_SEGMENT_POST_SAVE_BATCH_SIZEso many saves in oneatomic()produce one task per chunk per tenant. Routed torealtime_p3for both creates and updates (seeOBSERVATION_SEGMENT_ASYNC_*_QUEUEinobservations/signals.py). The legacy single-idobservations.tasks.update_observation_segments_for_observation_taskis retained only for in-flight messages from prior deploys (no producer in this codebase still enqueues it). Thereconcile-observation-segmentsjob above is the daily safety net that catches anything missed by this path.Operator-triggered (not scheduled):
observations.tasks.bump_observation_segment_tile_cache_for_tenant_taskis enqueued bymanage.py bust_observation_tile_cache --enqueueto bump the per-tenant segment tile version (O(1) Redis INCR) so cached MVT keys miss without a SCAN. Routed to themaintenancequeue.