: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 stale delta handle version regression as transient (#115688)
Tom Owers88f5eb1169fe
diff --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 9b87d032cc2e..298eaaaa1260 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@@ -196,7 +196,20 @@ def is_transient_delta_maintenance_error(error: BaseException) -> bool:# corrupt table can also raise, and those stay captured. Covers both delta-rs's older# `FileNotFoundError`-style message ("File not found: ...") and its Arrow/object_store kernel message# for the same underlying condition ("Object at location ... not found: ... 404 Not Found").- return "_delta_log/" in text and "not found" in text+ if "_delta_log/" in text and "not found" in text:+ return True++ # Yet another shape of the same reset-vs-stale-handle race: `DeltaTableRef._refresh_cached_table`+ # calls `update_incremental()` on a delta-rs handle that a prior write or `note_deltalite_commit`+ # already advanced to some version. If `reset_table` (or a repartition swap) replaces `_delta_log`+ # under this ref — most commonly the live attempt resyncing while a heartbeat-timed-out zombie+ # attempt still holds this older handle (see this package's README on the equivalent unfenced race+ # for repartition) — the log the refresh reads back is the fresh, lower-numbered one. Delta logs+ # are append-only, so the kernel refuses to apply that as an increment: "Unexpected state: the+ # newest version in the log {low} is older than the existing snapshot version {high}". The live+ # table itself is unaffected; only this stale handle's refresh failed, so the next reader (a+ # retried activity opens a fresh `DeltaTableRef`) reads the current log and succeeds.+ return "is older than the existing snapshot version" in text# `optimize.compact` bins files to rewrite by their on-disk (compressed) size, targetingdiff --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 1c5d392602a7..9dc379e06bc8 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@@ -215,6 +215,18 @@ class TestIsTransientDeltaMaintenanceError:# "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),+ # A reset or repartition swap replaced `_delta_log` under a handle that a prior write (or+ # note_deltalite_commit) had already advanced further: `update_incremental` refuses to apply+ # the now-lower-numbered log as an increment. Same reset-vs-stale-handle race as the missing+ # log file cases above, just surfaced by the kernel's monotonic-version check instead.+ (+ "snapshot_ahead_of_reset_log",+ deltalake.exceptions.DeltaError(+ "Kernel error: Generic delta kernel error: Unexpected state: the newest version in the "+ "log 11 is older than the existing snapshot version 15"+ ),+ True,+ ),# 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.