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(data-warehouse): restore sync failed and recovered alerts (#115891)

Thomas Obermüller33355aab3809
diff --git a/products/data_warehouse/backend/logic/external_data_source/jobs.py b/products/data_warehouse/backend/logic/external_data_source/jobs.py
index 49fec32f65f2..e9153eccb0eb 100644
--- a/products/data_warehouse/backend/logic/external_data_source/jobs.py
+++ b/products/data_warehouse/backend/logic/external_data_source/jobs.py
@@ -153,6 +153,10 @@ def update_external_job_status(
# moves: billing is what blocks this schema now.
billing_limited_run = schema_status == ExternalDataSchemaStatus.BILLING_LIMIT_REACHED
+ # Read the streak before this run moves it. The sync alerts decide "first failure" and
+ # "recovered" from the streak of the earlier runs, not from a streak that includes this run.
+ previous_failed_runs = schema.failed_runs_in_a_row
+
# The streak moves for a halted schema too. Its schedule keeps running, and the streak is
# the only thing that spaces out those runs, so skipping it lets a source that never
# answers fail on every slot.
@@ -172,7 +176,6 @@ def update_external_job_status(
else:
schema_status_written = True
previous_schema_status = schema.status
- previous_failed_runs = schema.failed_runs_in_a_row
schema.status = schema_status
if not billing_limited_run:
schema.latest_error = error_to_persist