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.

chore(replay-vision): spread out the read meter and back off rejected sweep queries (#115284)

Vasco de Krijgerba53182c3fca
diff --git a/products/replay_vision/backend/temporal/read_meter.py b/products/replay_vision/backend/temporal/read_meter.py
index 45ab0a7eb109..1d4bbbcadae6 100644
--- a/products/replay_vision/backend/temporal/read_meter.py
+++ b/products/replay_vision/backend/temporal/read_meter.py
@@ -57,7 +57,8 @@ async def create_replay_vision_read_meter_schedule(client: "Client") -> None:
workflow_id=READ_METER_WORKFLOW_ID,
inputs=MeterScannerReadsInputs(),
interval=READ_METER_INTERVAL,
- offset=dt.timedelta(minutes=2),
- jitter=dt.timedelta(minutes=10),
+ # Runs at :25 to keep it away from the API query surge at the top of the hour.
+ offset=dt.timedelta(minutes=25),
+ jitter=dt.timedelta(minutes=5),
execution_timeout=READ_METER_EXECUTION_TIMEOUT,
)
diff --git a/products/replay_vision/backend/temporal/sweep_workflow.py b/products/replay_vision/backend/temporal/sweep_workflow.py
index b07ff79c1540..51b07265f561 100644
--- a/products/replay_vision/backend/temporal/sweep_workflow.py
+++ b/products/replay_vision/backend/temporal/sweep_workflow.py
@@ -95,19 +95,22 @@ class SweepScannerWorkflow(PostHogWorkflow):
)
return
- # Retries target fast ClickHouse admission rejections (code 202); schedule_to_close deliberately
- # cuts slow timeout-bound attempts off after two rounds so the tick fails with ~10 minutes of the
- # 15-minute workflow budget left, instead of burning it on a query that keeps timing out.
+ # Retries target fast ClickHouse admission rejections (code 202). The waits are long enough for a
+ # burst to drain, so retries do not take the slots that free up first from API queries. The next
+ # tick starts in 5 minutes and the watermark stays put, so a failed tick loses nothing.
+ # schedule_to_close deliberately cuts slow timeout-bound attempts off after two rounds so the tick
+ # fails with ~10 minutes of the 15-minute workflow budget left, instead of burning it on a query
+ # that keeps timing out.
find_result = await wf.execute_activity(
find_scanner_candidates_activity,
FindScannerCandidatesInputs(scanner_id=inputs.scanner_id, team_id=inputs.team_id, candidate_limit=headroom),
start_to_close_timeout=FIND_SCANNER_CANDIDATES_TIMEOUT,
schedule_to_close_timeout=dt.timedelta(seconds=450),
retry_policy=common.RetryPolicy(
- initial_interval=dt.timedelta(seconds=5),
+ initial_interval=dt.timedelta(seconds=30),
backoff_coefficient=2.0,
- maximum_interval=dt.timedelta(seconds=30),
- maximum_attempts=4,
+ maximum_interval=dt.timedelta(seconds=120),
+ maximum_attempts=3,
),
)
# A no-op when both lists are empty. First failure aborts the gather and skips the advance;