: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 worker fd-exhaustion OSError as transient (#102808)
Tom Owers39078a3781d2
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 f1ee98c766f6..6b2eea168ba4 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@@ -1,3 +1,5 @@+import errno+from django.db import InterfaceError, InternalError, OperationalErrorimport psycopg.errors@@ -47,6 +49,13 @@ def is_transient_object_store_error(error: BaseException) -> bool:`object_store` crate. `NoCredentialsError`'s message is a fixed, generic string (no needle tomatch), but hitting our own instance-role-authenticated bucket always means the same transientresolution hiccup, so it's recognized by type rather than by message.++ A bare `OSError` with errno `EMFILE`/`ENFILE` means this worker's (or the system's) file+ descriptor table is full — e.g. `aget_s3_client`'s aiobotocore session bootstrap opening+ botocore's own bundled `endpoints.json` fails with this errno before any network call is even+ made. Same transient-capacity class already recognized on the postgres connect path+ (`_is_too_many_open_files_error`): a descriptor frees the moment another connection/client in+ this worker closes, so it's fd pressure on our side, never an object-store or customer problem."""if isinstance(error, TransientObjectStoreError | botocore.exceptions.NoCredentialsError):# Already classified and wrapped by a prior call to this same function (see@@ -54,6 +63,8 @@ def is_transient_object_store_error(error: BaseException) -> bool:# re-runs this classifier on the wrapper, rather than the original OSError/DeltaError it# wraps, must still treat it as transient.return True+ if isinstance(error, OSError) and error.errno in (errno.EMFILE, errno.ENFILE):+ return Truereturn isinstance(error, OSError | deltalake.exceptions.DeltaError) and any(needle in str(error) for needle in TRANSIENT_OBJECT_STORE_ERRORS)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 a8cba5db3d11..28bc327a0b49 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@@ -1,3 +1,5 @@+import errno+from django.db import InterfaceError, InternalError, OperationalErrorimport deltalake@@ -49,6 +51,26 @@ class TestIsTransientObjectStoreError:botocore.exceptions.NoCredentialsError(),True,),+ (+ # aiobotocore's session bootstrap (e.g. inside `aget_s3_client`) opens botocore's own+ # bundled endpoints.json before any network call is made - a full fd table fails that+ # local open the same way it fails a socket connect, so it needs the same transient+ # classification as the postgres connect-path EMFILE/ENFILE case.+ "fd_table_full_emfile",+ OSError(errno.EMFILE, "Too many open files"),+ True,+ ),+ (+ "fd_table_full_enfile",+ OSError(errno.ENFILE, "Too many open files in system"),+ True,+ ),+ (+ # A different errno must not be swept up by the fd-exhaustion check.+ "unrelated_os_error_with_errno",+ OSError(errno.ENOENT, "No such file or directory"),+ False,+ ),("unrelated_exception_type", ValueError("some other unrelated failure"), False),# `get_delta_table` re-raises a recognized transient blip as this wrapper (see# `_capture_unless_transient`) instead of the original OSError/DeltaError. A caller