: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
fix(conversations): move coordinator schedules off minute zero (#106994)
Sandy Spicer374b1e3330b8
diff --git a/posthog/tasks/scheduled.py b/posthog/tasks/scheduled.pyindex b0a9e6cd51b9..519da2e73042 100644--- a/posthog/tasks/scheduled.py+++ b/posthog/tasks/scheduled.py@@ -923,7 +923,7 @@ def setup_periodic_tasks(sender: Celery, **kwargs: Any) -> None:)sender.add_periodic_task(- crontab(hour="*", minute="0"),+ crontab(hour="*", minute="37"),stop_surveys_reached_target.s(),name="stop surveys that reached responses limits",)diff --git a/products/business_knowledge/backend/temporal/schedule.py b/products/business_knowledge/backend/temporal/schedule.pyindex b1ef646d2d26..4675096a9f7d 100644--- a/products/business_knowledge/backend/temporal/schedule.py+++ b/products/business_knowledge/backend/temporal/schedule.py@@ -15,6 +15,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_schedulefrom .learning.constants import LEARNING_COORDINATOR_INTERVAL_MINUTES@@ -34,7 +35,10 @@ async def create_business_knowledge_refresh_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),+ ),# SKIP plus the per-team advisory lock prevents concurrent double-refresh.policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP,@@ -56,7 +60,11 @@ async def create_business_knowledge_learning_coordinator_schedule(client: Clientid=LEARNING_SCHEDULE_ID,task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=interval)]),+ spec=ScheduleSpec(+ intervals=[+ ScheduleIntervalSpec(every=interval, offset=deterministic_offset(LEARNING_SCHEDULE_ID, interval))+ ]+ ),policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP,catchup_window=interval,diff --git a/products/conversations/backend/temporal/channel_summary/schedule.py b/products/conversations/backend/temporal/channel_summary/schedule.pyindex 00df63ac9844..938260d551b7 100644--- a/products/conversations/backend/temporal/channel_summary/schedule.py+++ b/products/conversations/backend/temporal/channel_summary/schedule.py@@ -41,7 +41,12 @@ async def create_channel_summary_coordinator_schedule(client: Client) -> None:id=CHANNEL_SUMMARY_COORDINATOR_SCHEDULE_ID,task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(minutes=COORDINATOR_INTERVAL_MINUTES))]),+ spec=ScheduleSpec(+ intervals=[+ ScheduleIntervalSpec(every=timedelta(minutes=COORDINATOR_INTERVAL_MINUTES), offset=timedelta(minutes=2))+ ],+ jitter=timedelta(minutes=10),+ ),policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),)diff --git a/products/conversations/backend/temporal/schedule.py b/products/conversations/backend/temporal/schedule.pyindex 9b34dee44333..5f9a6b46bbce 100644--- a/products/conversations/backend/temporal/schedule.py+++ b/products/conversations/backend/temporal/schedule.py@@ -17,6 +17,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_schedulefrom products.conversations.backend.temporal.coordinator import COORDINATOR_INTERVAL_MINUTES, CoordinatorInput@@ -38,7 +39,16 @@ async def create_support_reply_coordinator_schedule(client: Client) -> None:id=SUPPORT_REPLY_COORDINATOR_SCHEDULE_ID,task_queue=settings.VIDEO_EXPORT_TASK_QUEUE,),- spec=ScheduleSpec(intervals=[ScheduleIntervalSpec(every=timedelta(minutes=COORDINATOR_INTERVAL_MINUTES))]),+ spec=ScheduleSpec(+ intervals=[+ ScheduleIntervalSpec(+ every=timedelta(minutes=COORDINATOR_INTERVAL_MINUTES),+ offset=deterministic_offset(+ SUPPORT_REPLY_COORDINATOR_SCHEDULE_ID, timedelta(minutes=COORDINATOR_INTERVAL_MINUTES)+ ),+ )+ ]+ ),policy=SchedulePolicy(overlap=ScheduleOverlapPolicy.SKIP),)