: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-modeling): stop reporting transient DB drops from CDP row staging (#123252)
Tom Owersb7e55e5abfd6
diff --git a/posthog/temporal/data_modeling/activities/materialize_view.py b/posthog/temporal/data_modeling/activities/materialize_view.pyindex 5fa54affd84f..ea5ca735d127 100644--- a/posthog/temporal/data_modeling/activities/materialize_view.py+++ b/posthog/temporal/data_modeling/activities/materialize_view.py@@ -288,8 +288,9 @@ class _CDPRowSink:if self.enabled:await self._producer.clear()except Exception as e:- capture_exception(e)await self._logger.awarning(f"Could not prepare CDP row staging; skipping it for this run: {e}")+ if not is_transient_db_error(e):+ capture_exception(e)self.enabled = Falseasync def stage(self, batch: pa.RecordBatch) -> None:diff --git a/posthog/temporal/tests/data_modeling/test_materialize_view_staging.py b/posthog/temporal/tests/data_modeling/test_materialize_view_staging.pyindex 7d53ea91437b..9df4768c0c06 100644--- a/posthog/temporal/tests/data_modeling/test_materialize_view_staging.py+++ b/posthog/temporal/tests/data_modeling/test_materialize_view_staging.py@@ -129,3 +129,20 @@ class TestPropertySinkResolutionReportsOnlyNonTransientFailures:assert result is Falseassert mock_capture.called is expect_capture++ @parameterized.expand(+ [+ ("transient_connection_drop", OperationalError("server closed the connection unexpectedly"), False),+ ("other_error", RuntimeError("boom"), True),+ ]+ )+ async def test_cdp_row_sink_prepare(self, _name, error, expect_capture) -> None:+ producer = _producer()+ producer.should_run = AsyncMock(side_effect=error)+ sink = _CDPRowSink(producer, MagicMock(awarning=AsyncMock()))++ with patch("posthog.temporal.data_modeling.activities.materialize_view.capture_exception") as mock_capture:+ await sink.prepare()++ assert sink.enabled is False+ assert mock_capture.called is expect_capture