Skip to content

: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.

fix(data-imports): stop reporting an exhausted delta commit-conflict race (#122156)

Tom Owers00d3e0f81354
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.py
index 86c2c7daf8fd..f4f341a15f35 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
@@ -68,6 +68,7 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.arr
SchemaColumnTypeChangedException,
)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (
+ is_invalid_version_race,
is_transient_delta_maintenance_error,
is_transient_object_store_error,
)
@@ -1069,6 +1070,17 @@ async def _handle_import_error(
await logger.adebug("Transient Delta maintenance/reset race - re-raising for Temporal retry")
raise NonReportableError(error_msg) from error
+ # execute_with_conflict_retry (ops.py) already refreshes the table handle and retries this exact
+ # race a bounded number of times - sustained contention (most commonly a heartbeat-timed-out
+ # zombie attempt still committing against the same table during a rolling deploy, see
+ # batch_consumer.py's MAX_INTERRUPTIONS comment) can still exhaust that budget. The race is
+ # self-healing on the next attempt, same as the maintenance-path race above, so it must not be
+ # captured as a bug either.
+ if is_invalid_version_race(error):
+ await logger.awarning(error_msg)
+ await logger.adebug("Delta commit-conflict race exhausted its internal retries - 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 is
diff --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.py
index 340070351ed8..eaff04cfbdfa 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
@@ -885,6 +885,31 @@ async def test_transient_delta_maintenance_error_reraised_as_non_reportable():
logger.aexception.assert_not_awaited()
+async def test_invalid_version_race_reraised_as_non_reportable():
+ # execute_with_conflict_retry (ops.py) already retries this exact race a bounded number of
+ # times; sustained contention (a zombie attempt still committing during a rolling deploy) can
+ # exhaust that budget and let the raw DeltaError escape here. Self-healing on the next Temporal
+ # attempt, same as the maintenance-path race above, so it must not be captured as a bug either.
+ error = deltalake.exceptions.DeltaError("Invalid table version: 124")
+ 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(
[
(