: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): don't report non-reportable errors after retries (#110284)
Tom Owersc24717a4b5ad
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.pyindex 7a0e703274eb..b96f052ac0c8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/test_consumer.py@@ -17,6 +17,9 @@ from products.warehouse_sources.backend.models.external_data_schema import (SYNC_DISABLED_JOB_ERROR,)from products.warehouse_sources.backend.temporal.data_imports.metrics import LOCK_TAKEOVER_LATEST_ERROR+from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (+ TransientObjectStoreError,+)from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline_v3.postgres_queue import (consumer as consumer_module,)@@ -318,6 +321,57 @@ class TestProcessSingle:mock_fail.assert_called_once()+ @pytest.mark.asyncio+ async def test_non_reportable_error_skips_error_tracking_even_at_max_attempts(self):+ # A sustained S3/object-store blip (TransientObjectStoreError, a NonReportableError+ # subclass) is retryable in principle, so it must still reach error tracking only via+ # the classification made further down the stack, not get captured just because this+ # batch's own retry budget ran out.+ consumer = _make_consumer(max_attempts=2)+ batch = _make_batch(latest_attempt=1)+ consumer._process_batch = AsyncMock(side_effect=TransientObjectStoreError("Generic S3 error"))++ with (+ patch(+ "products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline_v3.postgres_queue.consumer.BatchQueue.update_status_unless_failed",+ new_callable=AsyncMock,+ ),+ patch.object(consumer, "_fail_run", new_callable=AsyncMock) as mock_fail,+ patch.object(batch_consumer_module, "capture_exception") as mock_capture,+ ):+ await consumer._process_single(batch)++ mock_fail.assert_called_once()+ assert "max retries exceeded" in mock_fail.call_args[1]["reason"]+ mock_capture.assert_not_called()++ @pytest.mark.asyncio+ async def test_non_reportable_error_skips_error_tracking_on_first_attempt_too(self):+ # A NonReportableError can also match a non-retryable message pattern (e.g. a storage+ # backend out of disk space during a maintenance op) and fail on the very first attempt,+ # not just after exhausting retries — that branch needs the same classification check.+ consumer = _make_consumer(max_attempts=3)+ batch = _make_batch(latest_attempt=0)+ consumer._process_batch = AsyncMock(+ side_effect=TransientObjectStoreError(+ "[Errno 5] An error occurred (XMinioStorageFull) when calling the CopyObject operation: "+ "Storage backend has reached its minimum free drive threshold."+ )+ )++ with (+ patch(+ "products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline_v3.postgres_queue.consumer.BatchQueue.update_status_unless_failed",+ new_callable=AsyncMock,+ ),+ patch.object(consumer, "_fail_run", new_callable=AsyncMock) as mock_fail,+ patch.object(batch_consumer_module, "capture_exception") as mock_capture,+ ):+ await consumer._process_single(batch)++ mock_fail.assert_called_once()+ mock_capture.assert_not_called()+class TestProcessGroup:@pytest.mark.asynciodiff --git a/products/warehouse_sources_queue/backend/core/batch_consumer.py b/products/warehouse_sources_queue/backend/core/batch_consumer.pyindex bea94824d69f..c97f1d69f02f 100644--- a/products/warehouse_sources_queue/backend/core/batch_consumer.py+++ b/products/warehouse_sources_queue/backend/core/batch_consumer.py@@ -17,6 +17,7 @@ import psycopgimport structlogfrom posthog.exceptions_capture import capture_exception+from posthog.temporal.common.errors import NonReportableErrorfrom products.warehouse_sources_queue.backend.core.batch_phase import (BatchPhaseProgress,@@ -1464,6 +1465,17 @@ class BatchConsumer:attempt=attempt,error=str(err),)+ elif isinstance(err, NonReportableError):+ # Classified as a known-transient or expected condition further down the stack+ # (e.g. DeltaTableRef._capture_unless_transient) — that classification already+ # decided this is noise, regardless of the adapter's own message-pattern checks.+ logger.warning(+ self._event("batch_failed_non_retryable"),+ batch_id=batch.id,+ run_uuid=batch.run_uuid,+ attempt=attempt,+ error=str(err),+ )else:logger.exception(self._event("batch_failed_non_retryable"),@@ -1476,13 +1488,25 @@ class BatchConsumer:await self._fail_run(batch, reason=reason, conn=lock_conn)elif attempt >= self._config.max_attempts:reason = f"max retries exceeded: {err}"- logger.exception(- self._event("batch_failed_no_retries_left"),- batch_id=batch.id,- run_uuid=batch.run_uuid,- attempt=attempt,- )- capture_exception(err)+ if isinstance(err, NonReportableError):+ # A sustained blip (e.g. TransientObjectStoreError) stays out of error tracking+ # even once this batch's own retry budget runs out — it's still an infra+ # condition, not a pipeline defect, no matter how many attempts it survived.+ logger.warning(+ self._event("batch_failed_no_retries_left"),+ batch_id=batch.id,+ run_uuid=batch.run_uuid,+ attempt=attempt,+ error=str(err),+ )+ else:+ logger.exception(+ self._event("batch_failed_no_retries_left"),+ batch_id=batch.id,+ run_uuid=batch.run_uuid,+ attempt=attempt,+ )+ capture_exception(err)await self._verify_ownership(lock_conn, batch)await self._fail_run(batch, reason=reason, conn=lock_conn)else: