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): treat s3 503 service unavailable as a transient blip (#115312)

Tom Owers563e6adfca27
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.py
index 692dd15853b4..9b87d032cc2e 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
@@ -93,6 +93,12 @@ def is_transient_object_store_error(error: BaseException) -> bool:
(`_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.
+ A bare `OSError` with errno `EBUSY` is s3fs's translation of every S3 "back off" response
+ (`SlowDown`, `ServiceUnavailable`, `OperationAborted`, a bare 503/409; see
+ `s3fs/errors.py::translate_boto_error`), raised once s3fs's own retries are exhausted. The errno
+ covers the 503 "Service Unavailable" case the message needles below miss, without matching on
+ the vendor's free text.
+
A bodyless 5xx that pyarrow's S3FileSystem reports as "AWS Error UNKNOWN" (see
`_is_bodyless_5xx_unknown_error`) is also transient - but only once its status is confirmed to be
5xx, because AWS omits the error body (and so reports the same UNKNOWN code) for a permanent
@@ -120,7 +126,7 @@ 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):
+ if isinstance(error, OSError) and error.errno in (errno.EMFILE, errno.ENFILE, errno.EBUSY):
return True
if isinstance(error, OSError) and _is_bodyless_5xx_unknown_error(error):
return True
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.py
index 9bdec8d23582..1c5d392602a7 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
@@ -82,6 +82,11 @@ class TestIsTransientObjectStoreError:
OSError(errno.ENFILE, "Too many open files in system"),
True,
),
+ (
+ "s3_service_unavailable_ebusy",
+ OSError(errno.EBUSY, "Service Unavailable"),
+ True,
+ ),
(
# A different errno must not be swept up by the fd-exhaustion check.
"unrelated_os_error_with_errno",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/util.py b/products/warehouse_sources/backend/temporal/data_imports/util.py
index 9deca6059a54..f1099d0ab74f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/util.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/util.py
@@ -741,7 +741,12 @@ async def prepare_s3_files_for_querying(
continue
await _log(f"Error while deleting old query folder {file}: {e}", level="error")
- if not (_is_transient_s3_connection_error(e) or is_transient_object_store_error(e)):
+ # Throttling that outlasted the retry budget is no longer a blip that
+ # clears on its own, so it is reported even though the classifier
+ # treats a single throttled response as transient.
+ if _is_s3_throttling_error(e) or not (
+ _is_transient_s3_connection_error(e) or is_transient_object_store_error(e)
+ ):
capture_exception(S3OperationError("delete an old query folder for this table", e))
# Cleanup stays best effort: the folder is timestamped, so the age-based
# GC above picks it up on a later sync. Failing the sync over it would