: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): stop reporting a clock-skew S3 delete as a bug (#105307)
Tom Owersc9556599d5a0
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 c16ca57c62a3..479e212db437 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@@ -16,6 +16,11 @@ from posthog.temporal.common.errors import NonReportableError# when a bulk operation (e.g. `_purge_s3_prefix`'s list-then-delete) outruns the bucket's request-rate limit# - "We encountered an internal error. Please try again." is S3's fixed message for its InternalError# (500) response, surfaced by s3fs/aiobotocore as an OSError once its own request retries are exhausted+# - "The difference between the request time and the current time is too large." is S3's fixed message+# for RequestTimeTooSkewed, raised when the worker's clock has drifted from S3's. s3fs maps every 403+# onto the same generic PermissionError (s3fs/errors.py::translate_boto_error), so this message - not+# a permission denial - is the only way to tell the two apart. The worker's own clock resyncs and the+# identical request succeeds moments later.# A retry (of the same idempotent operation) clears these, so they shouldn't be treated the same as a# bug in our logic.TRANSIENT_OBJECT_STORE_ERRORS = (@@ -24,6 +29,7 @@ TRANSIENT_OBJECT_STORE_ERRORS = ("Generic S3 error","Please reduce your request rate","We encountered an internal error. Please try again.",+ "The difference between the request time and the current time is too large.",)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 ef11f0dc66fa..b5725b49293f 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,15 @@ class TestIsTransientObjectStoreError:False,),("unrelated_exception_type", ValueError("some other unrelated failure"), False),+ (+ # s3fs maps every 403 onto the same generic PermissionError+ # (s3fs/errors.py::translate_boto_error), so RequestTimeTooSkewed (the worker's clock+ # drifting from S3's) reaches us with this exact fixed message instead of a real+ # AccessDenied - and clears on its own once the worker's clock resyncs.+ "s3_clock_skew_permission_error",+ PermissionError("The difference between the request time and the current time is too large."),+ True,+ ),# `get_delta_table` re-raises a recognized transient blip as this wrapper (see# `_capture_unless_transient`) instead of the original OSError/DeltaError. A caller# further up the stack that catches broadly and re-runs this classifier on the caughtdiff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.py b/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.pyindex d5b7c6cf4850..8240e0a4193e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/test_util.py@@ -398,6 +398,31 @@ async def test_delete_folder_swallows_transient_s3_connection_error(mock_capturemock_capture_exception.assert_not_called()+@patch(f"{_UTIL_MODULE}.capture_exception")+async def test_delete_folder_swallows_s3_clock_skew_error(mock_capture_exception: MagicMock) -> None:+ # S3 rejects a signed request whose clock has drifted too far from its own with+ # RequestTimeTooSkewed, which s3fs maps onto the same generic PermissionError as a real access+ # denial. The worker's own clock resyncs and the identical delete succeeds later, so this must+ # not mint an error-tracking issue any more than a connection blip would.+ s3 = _mock_s3()+ s3._rm = AsyncMock(+ side_effect=PermissionError("The difference between the request time and the current time is too large.")+ )++ with _mock_s3_context(s3):+ await prepare_s3_files_for_querying(+ folder_path="job",+ table_name="events",+ file_uris=[],+ use_timestamped_folders=False,+ delete_existing=True,+ )++ s3._rm.assert_awaited_once()+ mock_capture_exception.assert_not_called()++@pytest.mark.asyncio@patch(f"{_UTIL_MODULE}.capture_exception")async def test_delete_folder_still_captures_non_transient_error(mock_capture_exception: MagicMock) -> None:diff --git a/products/warehouse_sources/backend/temporal/data_imports/util.py b/products/warehouse_sources/backend/temporal/data_imports/util.pyindex 9f5391573c86..c95b049441e7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/util.py+++ b/products/warehouse_sources/backend/temporal/data_imports/util.py@@ -354,7 +354,7 @@ async def prepare_s3_files_for_querying(continueawait _log(f"Error while deleting old query folder {file}: {e}", level="error")- if not _is_transient_s3_connection_error(e):+ if 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