: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(data-warehouse): space out failing runs of a cdc-halted schema (#114466)
Tom Owersc266f8462680
diff --git a/products/data_warehouse/backend/logic/external_data_source/jobs.py b/products/data_warehouse/backend/logic/external_data_source/jobs.pyindex 09851ec92df4..1532099b68f7 100644--- a/products/data_warehouse/backend/logic/external_data_source/jobs.py+++ b/products/data_warehouse/backend/logic/external_data_source/jobs.py@@ -149,6 +149,13 @@ def update_external_job_status(# moves: billing is what blocks this schema now.billing_limited_run = schema_status == ExternalDataSchemaStatus.BILLING_LIMIT_REACHED+ # 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.+ streak_moved = is_first_terminal_transition and _move_failure_streak(+ schema, status, counts_as_source_failure=counts_as_source_failure+ )+if schema.cdc_halted:logger.info("dwh_schema_status_update_skipped_cdc_halted",@@ -156,14 +163,14 @@ def update_external_job_status(schema_id=str(schema.id),requested_status=schema_status,)+ if streak_moved:+ schema.save(update_fields=["sync_type_config", "updated_at"])else:schema.status = schema_statusif not billing_limited_run:schema.latest_error = error_to_persistschema_update_fields = ["status", "latest_error", "updated_at"]- if is_first_terminal_transition and _move_failure_streak(- schema, status, counts_as_source_failure=counts_as_source_failure- ):+ if streak_moved:schema_update_fields.append("sync_type_config")schema.save(update_fields=schema_update_fields)diff --git a/products/data_warehouse/backend/logic/external_data_source/test/test_jobs.py b/products/data_warehouse/backend/logic/external_data_source/test/test_jobs.pyindex ca2381e5ba9d..36880fb8f865 100644--- a/products/data_warehouse/backend/logic/external_data_source/test/test_jobs.py+++ b/products/data_warehouse/backend/logic/external_data_source/test/test_jobs.py@@ -451,6 +451,31 @@ class TestUpdateExternalJobStatus:assert last_failed_at.tzinfo is not Noneassert before - timedelta(seconds=1) <= last_failed_at <= datetime.now(UTC) + timedelta(seconds=1)+ @pytest.mark.parametrize(+ "halting_marker",+ [+ {"cdc_broken": {"reason": "slot_missing", "at": "2026-06-29T10:40:00+00:00"}},+ {"cdc_extraction_paused": {"reason": "auth_failed", "at": "2026-06-29T10:40:00+00:00"}},+ ],+ )+ def test_a_failed_run_of_a_cdc_halted_schema_still_moves_the_streak(self, halting_marker):+ team, _source, schema, job = _create_org_team_source_schema_job()+ schema.sync_type_config = {+ **halting_marker,+ "failure_streak": {"runs": 4, "last_failed_at": datetime.now(UTC).isoformat()},+ }+ schema.status = ExternalDataSchemaStatus.FAILED+ schema.latest_error = "The replication slot no longer exists on the source database."+ schema.save()++ self._finalize(team, job, ExternalDataJobStatus.FAILED)++ schema = ExternalDataSchema.objects.get(id=schema.id)+ assert schema.failed_runs_in_a_row == 5+ assert schema.cdc_halted+ assert schema.status == ExternalDataSchemaStatus.FAILED+ assert schema.latest_error == "The replication slot no longer exists on the source database."+def test_a_repeated_failed_write_for_the_same_job_does_not_count_again(self):team, _source, schema, job = _create_org_team_source_schema_job()schema.sync_type_config = {"failure_streak": {"runs": 2, "last_failed_at": datetime.now(UTC).isoformat()}}