: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 tracking transient S3 credential errors in delta maintenance (#73139)
Tom Owers8025d1bbea67
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.pyindex a5b1161fd964..b7faf622de95 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/extract.py@@ -17,6 +17,7 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.common.lfrom products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.cdp_producer import CDPProducerfrom products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.delta_table_helper import (DeltaTableHelper,+ is_transient_object_store_error,)from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.person_property_row_sink import (PersonPropertyRowSink,@@ -693,6 +694,9 @@ async def run_pre_write_defensive_compact(the CDC post-load path in `common/load.py` writes the same watermark, and both mergevia `update_sync_type_config_keys` under a row lock. Wrapped in try/except so amaintenance failure never blocks the actual sync; the original error path is unaffected.+ A transient object-store error (see `is_transient_object_store_error`) is logged at+ warning instead of captured — the next sync's maintenance pass retries it from scratch,+ so it isn't a bug in this function, just a temporary blip talking to our own S3 bucket.Used by both `PipelineNonDLT.run` (v2) and `PipelineV3.run` to keep the behaviouridentical across pipelines without each having to know how to look up `partition_count`@@ -716,5 +720,8 @@ async def run_pre_write_defensive_compact(schema.id, schema.team_id, updates={"last_vacuum_version": new_version})except Exception as e:+ if is_transient_object_store_error(e):+ await logger.awarning(f"Pre-write maintenance skipped: transient object-store error: {e}")+ returncapture_exception(e)await logger.aexception(f"Pre-write maintenance failed: {e}", exc_info=e)diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_extract.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_extract.pyindex 03897e0dcff3..e0e180a11671 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_extract.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/common/test/test_extract.py@@ -167,6 +167,38 @@ class TestRunPreWriteDefensiveCompact:mock_capture.assert_called_once()logger.aexception.assert_awaited_once()+ @parameterized.expand(+ [+ (+ "credentials_loading",+ "Operation not supported: an error occurred while loading credentials: dispatch failure: timeout",+ ),+ (+ "credential_provider_not_enabled",+ "Operation not supported: the credential provider was not enabled: no providers in chain provided credentials",+ ),+ (+ "generic_s3_error",+ "Generic S3 error: Error getting list response body: operation timed out",+ ),+ ]+ )+ @pytest.mark.asyncio+ async def test_logs_transient_object_store_error_without_capturing(self, _name: str, error_message: str):+ # A transient blip talking to our own delta S3 bucket (credential-provider or connectivity+ # errors from delta-rs) isn't a bug in this function — it shouldn't flood error tracking the+ # way an actual maintenance bug does (see test_swallows_maintenance_failure above).+ helper = MagicMock(run_maintenance=AsyncMock(side_effect=OSError(error_message)))+ logger = MagicMock(aexception=AsyncMock(), awarning=AsyncMock())++ schema = MagicMock(partition_count=5, sync_type_config={})+ with patch(f"{_EXTRACT_MODULE}.capture_exception") as mock_capture:+ await run_pre_write_defensive_compact(helper, schema, MagicMock(partition_count=None), logger)++ mock_capture.assert_not_called()+ logger.awarning.assert_awaited_once()+ logger.aexception.assert_not_awaited()+class TestReportHeartbeatTimeoutRecording(BaseTest):def _schema(self) -> ExternalDataSchema:diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/delta_table_helper.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/delta_table_helper.pyindex 87821ee4ac3f..2e62d3493ca9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/delta_table_helper.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/delta_table_helper.py@@ -51,6 +51,21 @@ from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipelineDEFAULT_COMPACT_FILES_PER_PARTITION_THRESHOLD = 200DEFAULT_COMPACT_TOTAL_FILES_THRESHOLD = 5000+# Substrings of the `OSError`s delta-rs's Rust `object_store` crate raises from+# `DeltaTable.is_deltatable()` when it can't reach or authenticate against our own S3-backed+# data-warehouse bucket (IMDS/STS blips, dispatch timeouts) — not a customer credential problem.+# Transient and self-recovering: the next maintenance pass re-lists from scratch, so these+# shouldn't be treated the same as a bug in our maintenance logic.+TRANSIENT_OBJECT_STORE_ERRORS = (+ "an error occurred while loading credentials",+ "the credential provider was not enabled",+ "Generic S3 error",+)+++def is_transient_object_store_error(error: BaseException) -> bool:+ return isinstance(error, OSError) and any(needle in str(error) for needle in TRANSIENT_OBJECT_STORE_ERRORS)+def _delta_merge_spill_kwargs() -> dict[str, int]:"""delta-rs `merge` kwargs that let DataFusion spill to disk instead of OOMing on large merges.