: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
chore(experiments): stop sending the temporal fairness key on recalculations (#129827)
Rodrigo Iloro500f6ddd651e
diff --git a/products/experiments/backend/recalculation.py b/products/experiments/backend/recalculation.pyindex bda522a17665..24ee1a19b603 100644--- a/products/experiments/backend/recalculation.py+++ b/products/experiments/backend/recalculation.py@@ -288,9 +288,9 @@ def cancel_recalculation_workflow(recalculation_id: str) -> None:def start_metrics_recalculation_workflow(recalculation_id: str, *, team_id: int, organization_id: str) -> None:"""Dispatch the recalculation Temporal workflow for a row that request_recalculation just created.- Start every recalculation workflow through this function, so the workflow name and id, the task queue,- the org-scoped fairness key and the rollback stay in one place. If the start fails, the row is marked- FAILED when it is safe to do so, and the exception propagates to the caller.+ Start every recalculation workflow through this function, so the workflow name and id, the task queues+ and the rollback stay in one place. If the start fails, the row is marked FAILED when it is safe to do so,+ and the exception propagates to the caller."""try:temporal = sync_connect()@@ -299,7 +299,6 @@ def start_metrics_recalculation_workflow(recalculation_id: str, *, team_id: int,METRICS_RECALCULATION_WORKFLOW_NAME,ExperimentMetricsRecalculationWorkflowInputs(recalculation_id=recalculation_id,- fairness_key=organization_id,activity_task_queue=_activity_task_queue(organization_id),),id=metrics_recalculation_workflow_id(recalculation_id),diff --git a/products/experiments/backend/temporal/models.py b/products/experiments/backend/temporal/models.pyindex 683c8f77d55c..2604f348fff3 100644--- a/products/experiments/backend/temporal/models.py+++ b/products/experiments/backend/temporal/models.py@@ -112,9 +112,6 @@ class ExperimentMetricsRecalculationWorkflowInputs:"""Input to the batch metrics recalculation workflow."""recalculation_id: str # UUID as string- # Task-queue fairness key for the calc activities (the org id, matching the app_per_org limiter scope).- # None falls back to default dispatch order.- fairness_key: str | None = None# Task queue for the metric calculation activity, chosen when the run starts so replay stays deterministic.# None keeps the activity on the workflow's own queue.activity_task_queue: str | None = Nonediff --git a/products/experiments/backend/temporal/recalculation_workflow.py b/products/experiments/backend/temporal/recalculation_workflow.pyindex fccbf402047c..c66a0605d614 100644--- a/products/experiments/backend/temporal/recalculation_workflow.py+++ b/products/experiments/backend/temporal/recalculation_workflow.py@@ -2,7 +2,7 @@ import asynciofrom datetime import timedeltaimport temporalio.workflow-from temporalio.common import Priority, RetryPolicy+from temporalio.common import RetryPolicyfrom temporalio.exceptions import (ActivityError,ApplicationError,@@ -191,9 +191,6 @@ class ExperimentMetricsRecalculationWorkflow(PostHogWorkflow):heartbeat_timeout=timedelta(seconds=METRIC_CALC_HEARTBEAT_TIMEOUT_SECONDS),retry_policy=calc_retry_policy,task_queue=task_queue,- # Round-robin dispatch across orgs under backlog; a no-op on namespaces without- # fairness support.- priority=Priority(fairness_key=inputs.fairness_key),))results = await asyncio.gather(*calcs, return_exceptions=True)diff --git a/products/experiments/backend/test/test_metrics_recalculation_api.py b/products/experiments/backend/test/test_metrics_recalculation_api.pyindex 4922f9ae54ca..90bd2471f1de 100644--- a/products/experiments/backend/test/test_metrics_recalculation_api.py+++ b/products/experiments/backend/test/test_metrics_recalculation_api.py@@ -122,7 +122,6 @@ class TestMetricsRecalculationAPI(APIBaseTest):"experiment-metrics-recalculation-workflow",ExperimentMetricsRecalculationWorkflowInputs(recalculation_id=body["id"],- fairness_key=str(self.organization.id),activity_task_queue=expected_activity_task_queue,),id=f"experiment-metrics-recalculation-{body['id']}",