: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): classify a concurrent reset losing a delta log commit file as transient (#75240)
Tom Owersde3b3adbbc55
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.pyindex 183ed272ed8d..815cdaaf7852 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_load.py@@ -6,6 +6,7 @@ from unittest.mock import AsyncMock, MagicMock, patchfrom django.db import OperationalErrorimport pyarrow as pa+import deltalake.exceptionsfrom parameterized import parameterizedfrom products.warehouse_sources.backend.models.external_data_schema import ExternalDataSchema@@ -147,6 +148,15 @@ class TestRunPostLoadDeltaMaintenance:# sync's maintenance retries the same idempotent cleanup) and must not be promoted# into a fresh error-tracking issue — the regression this guards.("transient_s3_slowdown", OSError("Generic S3 error: Please reduce your request rate."), False),+ # Likewise for a concurrent-maintenance race: a full_refresh `reset_table` purging+ # `_delta_log` out from under this same compact/vacuum pass is self-healing, not a defect.+ (+ "transient_delta_maintenance_race",+ deltalake.exceptions.DeltaError(+ "Generic error: Kernel error: File not found: table/_delta_log/00000000000000000001.json"+ ),+ False,+ ),])@pytest.mark.asynciodiff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.pyindex d3f93c9721d5..4ba9949de781 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/errors.py@@ -77,9 +77,21 @@ TRANSIENT_DELTA_MAINTENANCE_ERRORS = (def is_transient_delta_maintenance_error(error: BaseException) -> bool:- return isinstance(error, deltalake.exceptions.DeltaError) and any(- needle in str(error) for needle in TRANSIENT_DELTA_MAINTENANCE_ERRORS- )+ if not isinstance(error, deltalake.exceptions.DeltaError):+ return False++ text = str(error)+ if any(needle in text for needle in TRANSIENT_DELTA_MAINTENANCE_ERRORS):+ return True++ # The same race can also take a transaction-log commit file, not just a data file: `reset_table`+ # (full_refresh) purges the whole table prefix, `_delta_log` included, out from under a still-running+ # maintenance pass that opened the table before the purge landed. Neither `vacuum()` nor+ # `optimize.compact()` ever deletes a `_delta_log/*.json` commit file itself, so a missing one here+ # means something else raced the read rather than the table being corrupt. Matched on the log+ # directory specifically rather than on "File not found" alone, which a genuinely missing data file+ # or a truly corrupt table can also raise, and those stay captured.+ return "File not found" in text and "_delta_log/" in textdef is_transient_maintenance_error(error: BaseException) -> bool:diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_delta_errors.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_delta_errors.pyindex d60d63522dbc..ed2e44d25b0f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_delta_errors.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_delta_errors.py@@ -80,6 +80,20 @@ class TestIsTransientDeltaMaintenanceError:deltalake.exceptions.CommitFailedError("Metadata changed since last commit."),False,),+ # A concurrent `reset_table` purging the whole table prefix (a full_refresh sync) out from+ # under a still-running maintenance pass takes `_delta_log` with it, so the vacuum reading+ # the commit history loses a log file mid-read: same race, safe to skip and retry.+ (+ "missing_delta_log_commit_file",+ deltalake.exceptions.DeltaError(+ "Generic error: Kernel error: File not found: "+ "dlt/team_1_source_2/table/_delta_log/00000000000000000001.json"+ ),+ True,+ ),+ # "File not found" outside the log directory must not match, because a data file missing for+ # some other reason is a real failure to capture, not this specific log-commit race.+ ("file_not_found_outside_delta_log", deltalake.exceptions.DeltaError("File not found: some/file"), False),# Other DeltaErrors are real failures (e.g. a genuinely corrupt log) and must still be captured.("unrelated_delta_error", deltalake.exceptions.DeltaError("no protocol found in delta log"), False),# Same message shape but not the DeltaError type delta-rs actually raises for it.@@ -118,6 +132,17 @@ class TestIsTransientMaintenanceError:),True,),+ # A full_refresh `reset_table` purging `_delta_log` out from under a concurrent+ # vacuum. The maintenance call sites only consult this folded-in classifier, so the+ # signature has to reach them through here too.+ (+ "missing_delta_log_commit_file",+ deltalake.exceptions.DeltaError(+ "Generic error: Kernel error: File not found: "+ "dlt/team_1_source_2/table/_delta_log/00000000000000000001.json"+ ),+ True,+ ),("genuine_bug", RuntimeError("maintenance blew up"), False),])