Skip to content

: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.

fix(signals): move signals and review hog schedules off minute zero (#106993)

Sandy Spicerb606c4805e2d
diff --git a/products/review_hog/backend/temporal/outcomes_schedule.py b/products/review_hog/backend/temporal/outcomes_schedule.py
index fe4d8d841272..19174dff32ea 100644
--- a/products/review_hog/backend/temporal/outcomes_schedule.py
+++ b/products/review_hog/backend/temporal/outcomes_schedule.py
@@ -33,7 +33,10 @@ async def create_review_hog_finding_outcomes_schedule(client: Client) -> None:
id=SCHEDULE_ID,
task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,
),
- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=SCHEDULE_INTERVAL)]),
+ spec=ScheduleSpec(
+ intervals=[ScheduleIntervalSpec(every=SCHEDULE_INTERVAL, offset=timedelta(minutes=2))],
+ jitter=timedelta(minutes=10),
+ ),
policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP, catchup_window=SCHEDULE_INTERVAL),
)
diff --git a/products/signals/backend/emission/conversations_schedule.py b/products/signals/backend/emission/conversations_schedule.py
index 4e5d7dc4ceda..f93788104255 100644
--- a/products/signals/backend/emission/conversations_schedule.py
+++ b/products/signals/backend/emission/conversations_schedule.py
@@ -27,7 +27,10 @@ async def create_conversations_signals_coordinator_schedule(client: Client):
id=SCHEDULE_ID,
task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,
),
- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=SCHEDULE_INTERVAL)]),
+ spec=ScheduleSpec(
+ intervals=[ScheduleIntervalSpec(every=SCHEDULE_INTERVAL, offset=timedelta(minutes=2))],
+ jitter=timedelta(minutes=10),
+ ),
policy=SchedulePolicy(
overlap=ScheduleOverlapPolicy.SKIP,
catchup_window=SCHEDULE_INTERVAL,
diff --git a/products/signals/backend/ranking/schedule.py b/products/signals/backend/ranking/schedule.py
index d9601a9402d4..fb2e89a3fe21 100644
--- a/products/signals/backend/ranking/schedule.py
+++ b/products/signals/backend/ranking/schedule.py
@@ -15,6 +15,7 @@ from temporalio.client import (
ScheduleSpec,
)
+from posthog.scheduling.jitter import deterministic_offset
from posthog.temporal.common.schedule import a_create_schedule, a_schedule_exists, a_update_schedule
from products.signals.backend.ranking.sweep import SCORING_WORKFLOW_NAME, ScoreInboxReportsInput
@@ -38,7 +39,13 @@ async def create_inbox_ranking_scoring_schedule(client: Client) -> None:
task_queue=settings.SELF_DRIVING_TASK_QUEUE,
execution_timeout=interval,
),
- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=interval)]),
+ spec=ScheduleSpec(
+ intervals=[
+ ScheduleIntervalSpec(
+ every=interval, offset=deterministic_offset(INBOX_RANKING_SCORING_SCHEDULE_ID, interval)
+ )
+ ]
+ ),
policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),
)
if await a_schedule_exists(client, INBOX_RANKING_SCORING_SCHEDULE_ID):
diff --git a/products/signals/backend/temporal/agentic/schedule.py b/products/signals/backend/temporal/agentic/schedule.py
index a9d68ad35693..7a157adf7ae8 100644
--- a/products/signals/backend/temporal/agentic/schedule.py
+++ b/products/signals/backend/temporal/agentic/schedule.py
@@ -17,6 +17,7 @@ from temporalio.client import (
ScheduleSpec,
)
+from posthog.scheduling.jitter import deterministic_offset
from posthog.temporal.common.schedule import a_create_schedule, a_schedule_exists, a_update_schedule
from products.signals.backend.temporal.agentic.scout_coordinator import (
@@ -53,7 +54,16 @@ async def create_signals_scout_coordinator_schedule(client: Client) -> None:
task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,
execution_timeout=timedelta(minutes=COORDINATOR_INTERVAL_MINUTES),
),
- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(minutes=COORDINATOR_INTERVAL_MINUTES))]),
+ spec=ScheduleSpec(
+ intervals=[
+ ScheduleIntervalSpec(
+ every=timedelta(minutes=COORDINATOR_INTERVAL_MINUTES),
+ offset=deterministic_offset(
+ SIGNALS_SCOUT_COORDINATOR_SCHEDULE_ID, timedelta(minutes=COORDINATOR_INTERVAL_MINUTES)
+ ),
+ )
+ ]
+ ),
policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),
)
@@ -86,7 +96,14 @@ async def create_scout_suggestions_coordinator_schedule(client: Client) -> None:
execution_timeout=timedelta(minutes=SUGGESTIONS_COORDINATOR_INTERVAL_MINUTES),
),
spec=ScheduleSpec(
- intervals=[ScheduleIntervalSpec(every=timedelta(minutes=SUGGESTIONS_COORDINATOR_INTERVAL_MINUTES))]
+ intervals=[
+ ScheduleIntervalSpec(
+ every=timedelta(minutes=SUGGESTIONS_COORDINATOR_INTERVAL_MINUTES),
+ offset=deterministic_offset(
+ SUGGESTIONS_COORDINATOR_SCHEDULE_ID, timedelta(minutes=SUGGESTIONS_COORDINATOR_INTERVAL_MINUTES)
+ ),
+ )
+ ]
),
policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),
)
diff --git a/products/signals/dags/inbox_ranking/README.md b/products/signals/dags/inbox_ranking/README.md
index 8593d1683e43..0fe5140b043e 100644
--- a/products/signals/dags/inbox_ranking/README.md
+++ b/products/signals/dags/inbox_ranking/README.md
@@ -68,7 +68,7 @@ The first four are report grain and land in one table. `inbox_signal_embeddings`
## The training dag
-`inbox_ranking_training_job` runs daily at 06:00 UTC on the same partition definition (gated like the dataset job) and writes:
+`inbox_ranking_training_job` runs daily at 06:13 UTC on the same partition definition (gated like the dataset job) and writes:
```text
s3://<bucket>/<prefix>/
diff --git a/products/signals/dags/inbox_ranking/training/dag.py b/products/signals/dags/inbox_ranking/training/dag.py
index 61bb00dd950e..76f1a7b413b6 100644
--- a/products/signals/dags/inbox_ranking/training/dag.py
+++ b/products/signals/dags/inbox_ranking/training/dag.py
@@ -1392,7 +1392,7 @@ inbox_ranking_training_job = dagster.define_asset_job(
# Runs after the dataset job's 3h budget (02:30 UTC start) so dt=D-1's snapshots exist.
@dagster.schedule(
- cron_schedule="0 6 * * *",
+ cron_schedule="13 6 * * *",
job=inbox_ranking_training_job,
execution_timezone="UTC",
default_status=dagster.DefaultScheduleStatus.RUNNING