: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 db blips from repartition detection (#86025)
Tom Owersc0231b635d8e
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.pyindex 0cf141c23506..2d077c617f89 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/repartition_controller.py@@ -27,6 +27,9 @@ from posthog.utils import get_machine_idfrom products.warehouse_sources.backend.models.external_data_job import ExternalDataJobfrom products.warehouse_sources.backend.models.external_data_schema import ExternalDataSchemafrom products.warehouse_sources.backend.models.oom_event import ExternalDataSchemaOOMEvent+from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (+ is_transient_maintenance_error,+)from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.repartition import (measure_partition_bytes,select_coarsen_target,@@ -576,6 +579,16 @@ async def maybe_flag_for_repartition(target_size=target.partition_size,)except Exception as e:- # Detection is best-effort; never fail post-load over it.+ # Detection is best-effort; never fail post-load over it. `record_partition_measurement` and+ # the other DB writes above can hit a transient app-DB blip (pgbouncer pooler drop, or its+ # server_login_retry cooldown outliving retry_on_db_connection_drop's single retry) — the+ # same class of noise `_maybe_flag_pre_extraction` (repartition_table.py) already filters+ # out with this same classifier, so this best-effort detection function should too.+ if is_transient_maintenance_error(e):+ await logger.awarning(+ f"repartition: detection failed with a transient infra error schema_id={schema.id}",+ schema_id=str(schema.id),+ )+ returnawait logger.aexception(f"repartition: detection failed schema_id={schema.id}", schema_id=str(schema.id))capture_exception(e)diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.pyindex 12575a86155c..bba10e6c4a21 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/test_repartition_controller.py@@ -107,6 +107,30 @@ class TestRepartitionDetection:assert pending["trigger_reason"] == "proactive_threshold"assert capture.call_args.args[0] == "warehouse_repartition_flagged"+ def test_transient_db_error_during_measurement_save_is_not_captured(self, team):+ # A pgbouncer pooler drop (or its server_login_retry cooldown outliving the single retry in+ # retry_on_db_connection_drop) must not mint an error-tracking issue for a condition nobody+ # can act on — only a genuine detection bug should reach capture_exception.+ schema = _make_schema(+ team,+ {"partitioning_enabled": True, "partition_mode": "md5", "partition_count": 2, "partitioning_keys": ["id"]},+ )+ with tempfile.TemporaryDirectory() as d:+ delta = _write_partitioned_delta(f"{d}/t", ["0", "0", "1", "1"])+ with (+ patch.object(+ ExternalDataSchema,+ "record_partition_measurement",+ side_effect=OperationalError(+ "server login has been failing, cached error: server conn crashed? (server_login_retry)"+ ),+ ),+ patch.object(ctrl, "capture_exception") as mock_capture_exception,+ ):+ self._detect(team, schema, delta)++ mock_capture_exception.assert_not_called()+def test_unpartitioned_table_flags_auto_target_scheme(self, team):# An unpartitioned table's target legitimately has mode None (auto-detect at rewrite time),# but the flagged event must report "auto" — a null here NULL-poisons dashboard strings —