: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-imports): stop reporting transient repartition db blips to error tracking (#83877)
Tom Owersabe10ac3551f
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.pyindex 354cb63f1a70..5ffb5517bfc7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py@@ -441,7 +441,10 @@ def _maybe_repartition_table(inputs: RepartitionActivityInputs, logger: Filterinif _is_transient_infra_error(e):# Transient infra noise mid-repartition (app-DB pooler drop, S3 rate limit, credential# timeout) — not a repartition bug. The rewrite/swap is idempotent via the swap marker, so- # retrying is always safe. Don't consume an attempt or emit a failure event.+ # retrying is always safe. Don't consume an attempt, emit a failure event, or report to+ # error tracking — a condition nobody can act on (e.g. a pgbouncer login-retry cooldown)+ # shouldn't trip an issue there; the log line, the transient metric, and the skipped+ # event's reason="transient_infra_error" already carry the visibility.DELTA_REPARTITION_TOTAL.labels(team_id=str(inputs.team_id), outcome="transient").inc()if trigger_reason == "admin":# An operator staged this rewrite precisely because syncing on the old layout is@@ -459,7 +462,6 @@ def _maybe_repartition_table(inputs: RepartitionActivityInputs, logger: Filterintype="TransientRepartitionError",) from elogger.warning("repartition: transient infra error, will retry on next sync", exc_info=True)- capture_exception(e)_capture_stood_down(schema, inputs, trigger_reason, "transient_infra_error", logger)returnfailure_outcome = _handle_failure(inputs, schema, pending, trigger_reason, e, claim_token, logger)diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.pyindex 8237f61f776a..a979f0922238 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py@@ -335,6 +335,54 @@ class TestTransientObjectStoreFailure:schema.set_repartition_pending.assert_not_called()schema.clear_repartition_pending.assert_not_called()+ @parameterized.expand(+ [+ (+ "pgbouncer_login_retry",+ OperationalError(+ "server login has been failing, cached error: server conn crashed? (server_login_retry)"+ ),+ ),+ ("interface_error", InterfaceError("connection already closed")),+ ]+ )+ @patch(f"{MODULE}.capture_exception")+ @patch(f"{MODULE}.capture_repartition_event")+ @patch(f"{MODULE}.HeartbeaterSync")+ @patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)+ @patch(f"{MODULE}.DeltaTableRef")+ @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)+ @patch(f"{MODULE}.ExternalDataJob")+ @patch(f"{MODULE}.ExternalDataSchema")+ def test_db_connection_drop_stands_down_without_reporting_to_error_tracking(+ self,+ _name: str,+ error: Exception,+ mock_schema_model: MagicMock,+ _mock_job_model: MagicMock,+ _mock_enabled: MagicMock,+ _mock_helper_cls: MagicMock,+ mock_repartition: AsyncMock,+ _mock_heartbeater: MagicMock,+ mock_capture_event: MagicMock,+ mock_capture_exception: MagicMock,+ ) -> None:+ # A pgbouncer login-retry cooldown or a dropped pooled connection mid-rewrite is infra noise+ # nobody can act on, not a repartition bug — it must not trip a fresh error-tracking issue.+ # The transient metric and the skipped event's reason already carry the visibility.+ schema = _schema(name="public.usages", s3_folder_name="usages", pending={**PENDING_TARGET, "attempts": 0})+ mock_schema_model.objects.select_related.return_value.get.return_value = schema+ mock_repartition.side_effect = error++ _maybe_repartition_table(+ RepartitionActivityInputs(team_id=TEAM_ID, schema_id=SCHEMA_ID, job_id=JOB_ID, source_id=SOURCE_ID),+ MagicMock(),+ )++ mock_capture_exception.assert_not_called()+ skip_calls = [c for c in mock_capture_event.call_args_list if c.args[0] == "warehouse_repartition_skipped"]+ assert any(c.args[1].get("reason") == "transient_infra_error" for c in skip_calls)+class TestFeatureFlagGate:@parameterized.expand(