:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(scheduling): add stable offsets, move shared jobs off minute zero (#106984)
Sandy Spicer33f56d179269
diff --git a/.github/workflows/ci-dagster.yml b/.github/workflows/ci-dagster.ymlindex b9f65a9e69d9..2a461b200861 100644--- a/.github/workflows/ci-dagster.yml+++ b/.github/workflows/ci-dagster.yml@@ -162,6 +162,7 @@ jobs:- 'posthog/hogql/**'- 'posthog/hogql_queries/**'- 'posthog/query_cache/**'+ - 'posthog/scheduling/**'- 'posthog/settings/**'- 'posthog/kafka_client/**'- 'posthog/session/**'diff --git a/posthog/dags/distinct_id_usage.py b/posthog/dags/distinct_id_usage.pyindex bb13bb046bac..f19ceb0b1a02 100644--- a/posthog/dags/distinct_id_usage.py+++ b/posthog/dags/distinct_id_usage.py@@ -388,7 +388,7 @@ def distinct_id_usage_monitoring():distinct_id_usage_monitoring_schedule = dagster.ScheduleDefinition(job=distinct_id_usage_monitoring,- cron_schedule="0 */6 * * *", # Every 6 hours+ cron_schedule="27 */6 * * *", # Every 6 hoursexecution_timezone="UTC",name="distinct_id_usage_monitoring_schedule",)diff --git a/posthog/dags/postgres_to_clickhouse_etl.py b/posthog/dags/postgres_to_clickhouse_etl.pyindex 353452b5a23d..8aceb41195a1 100644--- a/posthog/dags/postgres_to_clickhouse_etl.py+++ b/posthog/dags/postgres_to_clickhouse_etl.py@@ -856,7 +856,7 @@ def postgres_to_clickhouse_etl_job():postgres_to_clickhouse_hourly_schedule = ScheduleDefinition(job=postgres_to_clickhouse_etl_job,- cron_schedule="0 * * * *",+ cron_schedule="17 * * * *",name="postgres_to_clickhouse_hourly",execution_timezone="UTC",)diff --git a/posthog/dags/tests/test_postgres_to_clickhouse_etl.py b/posthog/dags/tests/test_postgres_to_clickhouse_etl.pyindex 969dd2a2eb1b..9998619da005 100644--- a/posthog/dags/tests/test_postgres_to_clickhouse_etl.py+++ b/posthog/dags/tests/test_postgres_to_clickhouse_etl.py@@ -643,7 +643,7 @@ class TestDagsterWiring:def test_hourly_schedule_wires_to_etl_job(self):assert postgres_to_clickhouse_hourly_schedule.job_name == postgres_to_clickhouse_etl_job.name- assert postgres_to_clickhouse_hourly_schedule.cron_schedule == "0 * * * *"+ assert postgres_to_clickhouse_hourly_schedule.cron_schedule == "17 * * * *"assert postgres_to_clickhouse_hourly_schedule.execution_timezone == "UTC"@parameterized.expand(diff --git a/posthog/scheduling/__init__.py b/posthog/scheduling/__init__.pynew file mode 100644index 000000000000..e69de29bb2d1diff --git a/posthog/scheduling/jitter.py b/posthog/scheduling/jitter.pynew file mode 100644index 000000000000..223ed81faaa8--- /dev/null+++ b/posthog/scheduling/jitter.py@@ -0,0 +1,13 @@+"""Stable per-entity offsets for spreading scheduled work across a time window."""++import zlib+from datetime import timedelta+++def deterministic_offset(key: str, window: timedelta, *, floor: timedelta = timedelta(0)) -> timedelta:+ """An offset in `[floor, floor + window)`, at one-second resolution, that depends only on `key`."""+ window_seconds = int(window.total_seconds())+ if window_seconds < 1:+ return floor+ # crc32, not hash(): Python salts str hashes per process, and the offset must be the same after a restart.+ return floor + timedelta(seconds=zlib.crc32(key.encode()) % window_seconds)diff --git a/posthog/scheduling/test/test_jitter.py b/posthog/scheduling/test/test_jitter.pynew file mode 100644index 000000000000..06dc0476497b--- /dev/null+++ b/posthog/scheduling/test/test_jitter.py@@ -0,0 +1,20 @@+from datetime import timedelta++from parameterized import parameterized++from posthog.scheduling.jitter import deterministic_offset+++ [+ ("whole_window", timedelta(minutes=10), timedelta(0), timedelta(minutes=2, seconds=53)),+ ("after_floor", timedelta(minutes=12), timedelta(minutes=2), timedelta(minutes=12, seconds=53)),+ ("empty_window", timedelta(0), timedelta(minutes=2), timedelta(minutes=2)),+ ]+)+def test_deterministic_offset(_name: str, window: timedelta, floor: timedelta, expected: timedelta) -> None:+ assert deterministic_offset("alert-1", window, floor=floor) == expected++ offsets = [deterministic_offset(f"alert-{index}", window, floor=floor) for index in range(500)]+ assert min(offsets) >= floor+ assert max(offsets) <= floor + max(window - timedelta(seconds=1), timedelta(0))diff --git a/posthog/settings/schedules.py b/posthog/settings/schedules.pyindex 035bbcc42d7c..6ee67a984420 100644--- a/posthog/settings/schedules.py+++ b/posthog/settings/schedules.py@@ -4,15 +4,16 @@ from posthog.settings.utils import get_from_envUSE_PRECALCULATED_CH_COHORT_PEOPLE = not TEST# Schedules to recalculate cohorts. Follows crontab syntax.+# Skip minute zero so cohort recalculation does not join hourly batch starts.CALCULATE_COHORTS_DAY_SCHEDULE = get_from_env("CALCULATE_COHORTS_DAY_SCHEDULE",- "*/2 6-17 * * *",+ "1-59/2 6-17 * * *",)CALCULATE_X_PARALLEL_COHORTS_DURING_DAY = get_from_env("CALCULATE_X_PARALLEL_COHORTS_DURING_DAY", 5, type_cast=int)CALCULATE_COHORTS_NIGHT_SCHEDULE = get_from_env("CALCULATE_COHORTS_NIGHT_SCHEDULE",- "* 0-5,18-23 * * *",+ "1-59 0-5,18-23 * * *",)CALCULATE_X_PARALLEL_COHORTS_DURING_NIGHT = get_from_env("CALCULATE_X_PARALLEL_COHORTS_DURING_NIGHT", 5, type_cast=int)diff --git a/posthog/tasks/scheduled.py b/posthog/tasks/scheduled.pyindex daefce47d05f..3eb6a5d6de01 100644--- a/posthog/tasks/scheduled.py+++ b/posthog/tasks/scheduled.py@@ -311,7 +311,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:# Team metadata cache sync - hourlysender.add_periodic_task(- crontab(hour="*", minute="0"),+ crontab(hour="*", minute="13"),refresh_expiring_team_metadata_cache_entries.s(),name="team metadata cache sync",)@@ -349,7 +349,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:name="workflows email sending tier recomputation",)- # LLM gateway policy cache sync - hourly at :05 to stagger from team_metadata at :00+ # LLM gateway policy cache sync - hourly at :05 to stagger from team_metadata at :13sender.add_periodic_task(crontab(hour="*", minute="5"),refresh_expiring_llm_gateway_policy_cache_entries.s(),@@ -382,7 +382,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:# Stale QUEUED task run cleanup - hourlyadd_periodic_task_with_expiry(sender,- crontab(minute="0"),+ crontab(minute="19"),kill_stale_queued_task_runs.s(),name="kill stale queued task runs",)@@ -836,7 +836,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:name="PG table cache hit rate",)sender.add_periodic_task(- crontab(minute="0", hour="*"),+ crontab(minute="23", hour="*"),pg_plugin_server_query_timing.s(),name="PG plugin server query timing",)@@ -928,7 +928,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:)sender.add_periodic_task(- crontab(hour="*/12", minute="0"),+ crontab(hour="*/12", minute="41"),refresh_activity_log_fields_cache.s(),name="refresh activity log fields cache for large orgs",)@@ -994,7 +994,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:add_periodic_task_with_expiry(sender,- crontab(minute="0"),+ crontab(minute="43"),cleanup_old_scim_request_logs.s(),name="clean up old SCIM request logs",)@@ -1047,7 +1047,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:)sender.add_periodic_task(- crontab(hour="*", minute="0"),+ crontab(hour="*", minute="3"),validate_pending_change_requests.s(),name="validate pending change requests",)diff --git a/posthog/temporal/experiments/README.md b/posthog/temporal/experiments/README.mdindex 2e0bcf2382e1..96a2994e0e80 100644--- a/posthog/temporal/experiments/README.md+++ b/posthog/temporal/experiments/README.md@@ -4,7 +4,7 @@ This module calculates experiment metrics in the background using Temporal, a wo## How it works-Each team can configure one or two times of day when their experiments are recalculated, at least six hours apart (default: once at 02:00 UTC), via `TeamExperimentsConfig.experiment_recalculation_times`. The system runs 24 schedules - one for each hour of the day. When a schedule fires, it finds all experiments belonging to teams configured for that hour and calculates their metrics. A team with two configured times matches two schedules, so its experiments get two independent runs a day, each publishing its own recalculation.+Each team can configure one or two times of day when their experiments are recalculated, at least six hours apart (default: once at 02:00 UTC), via `TeamExperimentsConfig.experiment_recalculation_times`. The system runs 24 schedules - one for each hour of the day. Each schedule starts between 2 and 32 minutes past its hour, so the runs do not pile up with other jobs at minute zero. When a schedule fires, it finds all experiments belonging to teams configured for that hour and calculates their metrics. A team with two configured times matches two schedules, so its experiments get two independent runs a day, each publishing its own recalculation.```text┌─────────────────────────────────────────────────────────────────────────┐diff --git a/posthog/temporal/experiments/schedule.py b/posthog/temporal/experiments/schedule.pyindex d486985980a5..1f525634b996 100644--- a/posthog/temporal/experiments/schedule.py+++ b/posthog/temporal/experiments/schedule.py@@ -1,3 +1,5 @@+from datetime import timedelta+from django.conf import settingsfrom temporalio.client import Client, Schedule, ScheduleActionStartWorkflow, ScheduleSpec@@ -29,7 +31,7 @@ async def create_experiment_regular_metrics_schedules(client: Client) -> None:id=f'{SCHEDULE_ID_PREFIX}-{hour:02d}-{{{{.ScheduledTime.Format "2006-01-02"}}}}',task_queue=settings.GENERAL_PURPOSE_TASK_QUEUE,),- spec=ScheduleSpec(cron_expressions=[f"0 {hour} * * *"]),+ spec=ScheduleSpec(cron_expressions=[f"2 {hour} * * *"], jitter=timedelta(minutes=30)),)if await a_schedule_exists(client, schedule_id):@@ -71,7 +73,7 @@ async def create_experiment_saved_metrics_schedules(client: Client) -> None:id=f'{SAVED_SCHEDULE_ID_PREFIX}-{hour:02d}-{{{{.ScheduledTime.Format "2006-01-02"}}}}',task_queue=settings.GENERAL_PURPOSE_TASK_QUEUE,),- spec=ScheduleSpec(cron_expressions=[f"0 {hour} * * *"]),+ spec=ScheduleSpec(cron_expressions=[f"2 {hour} * * *"], jitter=timedelta(minutes=30)),)if await a_schedule_exists(client, schedule_id):diff --git a/posthog/temporal/health_checks/README.md b/posthog/temporal/health_checks/README.mdindex 5d9ae4dfb36a..aadb825ea8a8 100644--- a/posthog/temporal/health_checks/README.md+++ b/posthog/temporal/health_checks/README.md@@ -77,6 +77,7 @@ HEALTH_CHECK_MODULES = [### 3. DoneIf your class sets a `schedule`, a Temporal schedule is automatically created at deploy time via `init_schedules`. No additional wiring is needed.+The schedule adds up to 30 minutes of jitter, so a check starts within half an hour after its cron time.Omit `schedule` if you only want the check to be triggered manually from the admin UI.## `HealthCheck` class referencediff --git a/posthog/temporal/health_checks/schedule.py b/posthog/temporal/health_checks/schedule.pyindex 160807622988..c56541268a64 100644--- a/posthog/temporal/health_checks/schedule.py+++ b/posthog/temporal/health_checks/schedule.py@@ -1,4 +1,5 @@import dataclasses+from datetime import timedeltafrom django.conf import settings@@ -36,7 +37,9 @@ async def create_health_check_schedules(client: Client) -> None:id=f"health-check-{config.name}",task_queue=settings.HEALTH_CHECK_TASK_QUEUE,),- spec=ScheduleSpec(cron_expressions=[config.schedule]),+ # Checks look back a day or more, so a start up to 30 minutes after the cron time finds the same+ # issues. The jitter also stops checks that share a cron time from starting together.+ spec=ScheduleSpec(cron_expressions=[config.schedule], jitter=timedelta(minutes=30)),)if await a_schedule_exists(client, schedule_id):diff --git a/posthog/temporal/ingestion_acceptance_test/schedule.py b/posthog/temporal/ingestion_acceptance_test/schedule.pyindex 465fda556141..1af0a2e85b2f 100644--- a/posthog/temporal/ingestion_acceptance_test/schedule.py+++ b/posthog/temporal/ingestion_acceptance_test/schedule.py@@ -8,11 +8,13 @@ from django.conf import settingsfrom temporalio import commonfrom temporalio.client import Client, Schedule, ScheduleActionStartWorkflow, ScheduleIntervalSpec, ScheduleSpec+from posthog.scheduling.jitter import deterministic_offsetfrom posthog.temporal.common.schedule import a_create_schedule, a_delete_schedule, a_schedule_exists, a_update_schedulefrom posthog.temporal.ingestion_acceptance_test.config import configured_lanesfrom posthog.temporal.ingestion_acceptance_test.types import IngestionAcceptanceTestInputSCHEDULE_ID = "ingestion-acceptance-test-schedule"+SCHEDULE_INTERVAL = timedelta(minutes=15)WORKFLOW_NAME = "ingestion-acceptance-test"@@ -44,6 +46,7 @@ async def create_ingestion_acceptance_test_schedule(client: Client) -> None:def _build_schedule(inputs: IngestionAcceptanceTestInput) -> Schedule:+ schedule_id = _lane_schedule_id(inputs.lane) if inputs.lane else SCHEDULE_IDreturn Schedule(action=ScheduleActionStartWorkflow(WORKFLOW_NAME,@@ -54,7 +57,13 @@ def _build_schedule(inputs: IngestionAcceptanceTestInput) -> Schedule:maximum_attempts=1, # Don't retry - we want to know immediately if it fails),),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(minutes=15))]),+ spec=ScheduleSpec(+ intervals=[+ ScheduleIntervalSpec(+ every=SCHEDULE_INTERVAL, offset=deterministic_offset(schedule_id, SCHEDULE_INTERVAL)+ )+ ]+ ),)diff --git a/posthog/temporal/schedule.py b/posthog/temporal/schedule.pyindex 17fb729b7100..b7b67869ad70 100644--- a/posthog/temporal/schedule.py+++ b/posthog/temporal/schedule.py@@ -21,6 +21,7 @@ from temporalio.client import ()from posthog.cloud_utils import is_cloud+from posthog.scheduling.jitter import deterministic_offsetfrom posthog.slo.types import SloArea, SloConfig, SloOperationfrom posthog.temporal.ai.checkpoint_compaction.schedule import (create_checkpoint_compaction_schedule,@@ -583,7 +584,10 @@ async def create_ducklake_compaction_schedule(client: Client):initial_interval=timedelta(minutes=5),),),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(hours=1))]),+ spec=ScheduleSpec(+ intervals=[ScheduleIntervalSpec(every=timedelta(hours=1), offset=timedelta(minutes=2))],+ jitter=timedelta(minutes=10),+ ),)if await a_schedule_exists(client, "ducklake-compaction-schedule"):@@ -764,7 +768,14 @@ async def create_run_usage_reports_schedule(client: Client):task_queue=settings.BILLING_TASK_QUEUE,retry_policy=common.RetryPolicy(maximum_attempts=1),),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(minutes=30))]),+ spec=ScheduleSpec(+ intervals=[+ ScheduleIntervalSpec(+ every=timedelta(minutes=30),+ offset=deterministic_offset("run-usage-reports-schedule", timedelta(minutes=30)),+ )+ ]+ ),policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),)@@ -787,7 +798,7 @@ async def create_finalize_usage_reports_schedule(client: Client):the numbers are final for that date.02:45 leaves ~2.75 hours for ingestion lag after midnight and stays aheadof the legacy Celery run at 03:45 UTC. The intraday schedule now runs- every 30 minutes, so this slot sits between the 02:30 and 03:00 intraday+ every 30 minutes, so this slot sits between two intradayruns rather than clearing them by an hour, and the two schedules' SKIPpolicies don't see each other. A brief overlap is harmless: every runwrites under its own `{date}/{run_id}` S3 prefix, and the finalizerdiff --git a/products/context_layer/README.md b/products/context_layer/README.mdindex 3540c541c69f..e772b3eb6065 100644--- a/products/context_layer/README.md+++ b/products/context_layer/README.md@@ -53,6 +53,6 @@ Resolve those conflicts before retrying reconciliation. Existing pages are never## Dreaming-A nightly Temporal coordinator (`context-layer-dream-coordinator`, 03:00 UTC) dispatches one cloud task per enabled organization using GPT-5.6 Sol with high reasoning. Each tick dispatches up to 1,000 due organizations, least-recently-dreamt first. Before dispatch, deterministic reconciliation creates a project-scoped page for every public Space and regenerates the project and Space indexes. The run works unlocked on its own clone all night, on a dated `dream/<YYYY-MM-DD>` branch, and lands it through the commits endpoint as one two-parent merge commit (`dream: <date>`): `git log --merges` lists the dreams, and `git revert -m 1` undoes a whole night. The skills live in `products/context_layer/skills/` and source context from completed tasks and loops, merged PRs, and instrumented events. Activity pagination follows cursors until the window or budget is exhausted: up to 100 newest items total per Space across channel-scoped sources, and 100 per organization-wide source. Each run also rechecks completed tasks from the previous seven days so work that finishes after an earlier review is not lost behind the incremental cursor. A first dream includes empty public Space pages in its scan and fills them only when their channels have qualifying activity in the seed window. Dream branches may change sourced content pages only; the server rejects changes to repository instructions, generated indexes, scripts, or Space paths. A per-org failure streak pauses a lane after repeated dispatch failures (`ContextLayerConfig.dreaming_paused`).+A nightly Temporal coordinator (`context-layer-dream-coordinator`, between 03:02 and 03:32 UTC) dispatches one cloud task per enabled organization using GPT-5.6 Sol with high reasoning. Each tick dispatches up to 1,000 due organizations, least-recently-dreamt first. Before dispatch, deterministic reconciliation creates a project-scoped page for every public Space and regenerates the project and Space indexes. The run works unlocked on its own clone all night, on a dated `dream/<YYYY-MM-DD>` branch, and lands it through the commits endpoint as one two-parent merge commit (`dream: <date>`): `git log --merges` lists the dreams, and `git revert -m 1` undoes a whole night. The skills live in `products/context_layer/skills/` and source context from completed tasks and loops, merged PRs, and instrumented events. Activity pagination follows cursors until the window or budget is exhausted: up to 100 newest items total per Space across channel-scoped sources, and 100 per organization-wide source. Each run also rechecks completed tasks from the previous seven days so work that finishes after an earlier review is not lost behind the incremental cursor. A first dream includes empty public Space pages in its scan and fills them only when their channels have qualifying activity in the seed window. Dream branches may change sourced content pages only; the server rejects changes to repository instructions, generated indexes, scripts, or Space paths. A per-org failure streak pauses a lane after repeated dispatch failures (`ContextLayerConfig.dreaming_paused`).The Desktop context page reads the same history back: `GET context_layer/dreams/` returns the active dreaming task and lists the landed runs (subject, summary, page-change counts), while `GET context_layer/dreams/<sha>/` returns one run's per-file unified patches. Landed runs are derived from merge commits at request time and cached per head sha; active task state stays live.diff --git a/products/context_layer/backend/temporal/schedule.py b/products/context_layer/backend/temporal/schedule.pyindex b9dfdc0002ee..791139ea3ff3 100644--- a/products/context_layer/backend/temporal/schedule.py+++ b/products/context_layer/backend/temporal/schedule.py@@ -1,4 +1,5 @@from dataclasses import asdict+from datetime import timedeltafrom django.conf import settings@@ -28,7 +29,7 @@ async def create_context_layer_dream_schedule(client: Client) -> None:id=CONTEXT_LAYER_DREAM_SCHEDULE_ID,task_queue=settings.GENERAL_PURPOSE_TASK_QUEUE,),- spec=ScheduleSpec(cron_expressions=["0 3 * * *"]),+ spec=ScheduleSpec(cron_expressions=["2 3 * * *"], jitter=timedelta(minutes=30)),policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),)if await a_schedule_exists(client, CONTEXT_LAYER_DREAM_SCHEDULE_ID):diff --git a/products/data_warehouse/backend/logic/data_load/service.py b/products/data_warehouse/backend/logic/data_load/service.pyindex 88d6938db65f..8e6f206d0254 100644--- a/products/data_warehouse/backend/logic/data_load/service.py+++ b/products/data_warehouse/backend/logic/data_load/service.py@@ -26,6 +26,7 @@ from temporalio.client import (from temporalio.common import RetryPolicyfrom posthog.ph_client import feature_enabled_or_false+from posthog.scheduling.jitter import deterministic_offsetfrom posthog.temporal.common.client import async_connect, sync_connectfrom posthog.temporal.common.schedule import (a_create_schedule,@@ -508,7 +509,7 @@ def get_cdc_extraction_schedule()spec = ScheduleSpec(- intervals=[ScheduleIntervalSpec(every=min_interval)],+ intervals=[ScheduleIntervalSpec(every=min_interval, offset=deterministic_offset(str(source.id), min_interval))],)return Schedule(@@ -872,7 +873,10 @@ def ensure_cdc_slot_cleanup_schedule() -> None:schedule = Schedule(action=action,- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(hours=1))]),+ spec=ScheduleSpec(+ intervals=[ScheduleIntervalSpec(every=timedelta(hours=1), offset=timedelta(minutes=2))],+ jitter=timedelta(minutes=10),+ ),state=ScheduleState(note="Global CDC slot orphan cleanup and WAL lag monitor"),policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),)diff --git a/products/engineering_analytics/backend/logic/job_logs/schedule.py b/products/engineering_analytics/backend/logic/job_logs/schedule.pyindex 7f9fb41056c5..a5c0bf84dfb8 100644--- a/products/engineering_analytics/backend/logic/job_logs/schedule.py+++ b/products/engineering_analytics/backend/logic/job_logs/schedule.py@@ -18,6 +18,7 @@ from temporalio.client import (ScheduleSpec,)+from posthog.scheduling.jitter import deterministic_offsetfrom posthog.temporal.common.schedule import a_create_schedule, a_schedule_exists, a_update_scheduleSCHEDULE_ID = "github-job-logs-coordinator-schedule"@@ -31,7 +32,13 @@ async def create_github_job_logs_coordinator_schedule(client: Client) -> None:id=SCHEDULE_ID,task_queue=settings.GENERAL_PURPOSE_TASK_QUEUE,),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=SCHEDULE_INTERVAL)]),+ spec=ScheduleSpec(+ intervals=[+ ScheduleIntervalSpec(+ every=SCHEDULE_INTERVAL, offset=deterministic_offset(SCHEDULE_ID, SCHEDULE_INTERVAL)+ )+ ]+ ),# SKIP so a slow tick doesn't stack; the egress limiter (not cron frequency) caps spend.policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP, catchup_window=SCHEDULE_INTERVAL),)diff --git a/products/engineering_analytics/backend/logic/signals/schedule.py b/products/engineering_analytics/backend/logic/signals/schedule.pyindex 29a5c3154c40..35421b921a00 100644--- a/products/engineering_analytics/backend/logic/signals/schedule.py+++ b/products/engineering_analytics/backend/logic/signals/schedule.py@@ -34,7 +34,10 @@ async def create_ci_signals_coordinator_schedule(client: Client) -> None:# Bounded to the interval so a wedged sweep can never block more than one SKIP tick.execution_timeout=SCHEDULE_INTERVAL,),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=SCHEDULE_INTERVAL)]),+ spec=ScheduleSpec(+ intervals=[ScheduleIntervalSpec(every=SCHEDULE_INTERVAL, offset=timedelta(minutes=2))],+ jitter=timedelta(minutes=10),+ ),# SKIP so a slow tick doesn't stack; enrolment (not cron frequency) bounds the work.policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP, catchup_window=SCHEDULE_INTERVAL),)diff --git a/products/security/backend/temporal/schedule.py b/products/security/backend/temporal/schedule.pyindex ab0a2bf1fba8..c75a459c3c62 100644--- a/products/security/backend/temporal/schedule.py+++ b/products/security/backend/temporal/schedule.py@@ -14,6 +14,7 @@ from temporalio.client import ()from temporalio.common import RetryPolicy, WorkflowIDConflictPolicy, WorkflowIDReusePolicy+from posthog.scheduling.jitter import deterministic_offsetfrom posthog.temporal.common.client import sync_connectfrom posthog.temporal.common.schedule import a_create_schedule, a_schedule_exists, a_update_schedule@@ -32,7 +33,13 @@ async def create_sync_access_rules_schedule(client: Client) -> None:task_queue=settings.GENERAL_PURPOSE_TASK_QUEUE,execution_timeout=EXECUTION_TIMEOUT,),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=dt.timedelta(minutes=5))]),+ spec=ScheduleSpec(+ intervals=[+ ScheduleIntervalSpec(+ every=dt.timedelta(minutes=5), offset=deterministic_offset(SCHEDULE_ID, dt.timedelta(minutes=5))+ )+ ]+ ),policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),)if await a_schedule_exists(client, SCHEDULE_ID):