: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(warehouse-sources): treat parent-table delta races as transient (#109096)
Tom Owerscadfa8665870
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.pyindex cb589326d6e3..15723d7257b4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/import_data_sync.py@@ -51,6 +51,7 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.arrSchemaColumnTypeChangedException,)from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (+ is_transient_delta_maintenance_error,is_transient_object_store_error,)from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.repartition_controller import (@@ -893,6 +894,17 @@ async def _handle_import_error(await logger.adebug("Transient object-store error - re-raising for Temporal retry")raise NonReportableError(error_msg) from error+ # The same concurrent-maintenance/reset race `is_transient_delta_maintenance_error` already+ # covers for the writer's own table (a full-refresh purging `_delta_log` out from under a+ # still-running maintenance pass) can just as well hit a *parent* table a warehouse-parent+ # fan-out reader (sources/common/rest_source/warehouse_parent.py) opened at a pinned version:+ # the parent resyncs and resets its table between the pin and the read. Same self-healing+ # race, different table role, so classify it the same way here rather than letting it escape raw.+ if is_transient_delta_maintenance_error(error):+ await logger.awarning(error_msg)+ await logger.adebug("Transient Delta maintenance/reset race - re-raising for Temporal retry")+ raise NonReportableError(error_msg) from error+# DATA_WAREHOUSE_REDIS backs resumable-source checkpoints, row tracking, and sync locks — it's# PostHog's own instance, never anything a customer's source touches. A connectivity blip there# (unreachable, refusing connections while restarting) clears on its own once the instance isdiff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.pyindex 5ed4f047fd73..eae2cc3a51d9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_import_data_sync.py@@ -11,6 +11,7 @@ from unittest import mockfrom django.db import InterfaceError, InternalError, OperationalErrorimport redis.exceptions as redis_exceptions+import deltalake.exceptionsfrom jsonpath_ng.exceptions import JsonPathParserErrorfrom parameterized import parameterizedfrom requests.exceptions import HTTPError, ProxyError@@ -718,6 +719,34 @@ async def test_transient_object_store_error_reraised_as_non_reportable():logger.aexception.assert_not_awaited()+async def test_transient_delta_maintenance_error_reraised_as_non_reportable():+ # A warehouse-parent fan-out reader pins a parent table to a version, then opens it lazily —+ # if the parent resyncs and resets its table in between, the pinned version's `_delta_log`+ # entry is gone by the time the read happens. Self-healing on retry (a fresh pin resolves+ # against the post-reset table), so it must not be captured as a bug, same as the identical+ # race already classified for the writer's own maintenance path.+ error = deltalake.exceptions.DeltaError(+ "Kernel error: File not found: dlt/team_1_stripe_source/customer/_delta_log/00000000000000000017.json"+ )+ source = mock.MagicMock(spec=SimpleSource)+ source.get_non_retryable_errors.return_value = {}+ source.get_retryable_errors.return_value = set()++ logger = mock.MagicMock()+ logger.awarning = mock.AsyncMock()+ logger.aexception = mock.AsyncMock()+ logger.adebug = mock.AsyncMock()++ with mock.patch.object(module.SourceRegistry, "get_source", return_value=source):+ with pytest.raises(NonReportableError) as exc_info:+ await module._handle_import_error(mock.MagicMock(), logger, error)++ assert exc_info.value.__cause__ is error+ logger.awarning.assert_awaited_once()+ logger.aexception.assert_not_awaited()++@parameterized.expand([(