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-warehouse): treat a raced S3 NoSuchKey as transient during repartition (#83449)

Tom Owersa15efca27e06
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
index 3e3b212f6142..354cb63f1a70 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/repartition_table.py
@@ -85,6 +85,11 @@ _TRANSIENT_ERROR_SNIPPETS = (
"reduce your request rate", # S3 503 SlowDown surfaced by the delta kernel as OSError
"error occurred while loading credentials", # IMDS/credential-provider timeout inside the kernel
"event loop is closed", # s3fs client bound to an already-completed async_to_sync loop
+ # S3 NoSuchKey from an s3fs purge/swap op (`_copy`/`_rm`/`_find`) that raced a concurrent delete —
+ # a temp file swept by another attempt, not a bug. A hollow *live* table surfaces the missing file
+ # with its path embedded and is routed to a revive inside `repartition_table_in_place` before it
+ # ever reaches here, so this bare, pathless variant only ever means a raced object-store operation.
+ "the specified key does not exist",
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
index c4c2a1a0a5b0..8237f61f776a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/workflow_activities/tests/test_repartition_table.py
@@ -298,6 +298,44 @@ class TestBudgetExhaustion:
assert "warehouse_repartition_skipped" in emitted
+class TestTransientObjectStoreFailure:
+ @patch(f"{MODULE}.capture_exception")
+ @patch(f"{MODULE}.capture_repartition_event")
+ @patch(f"{MODULE}.HeartbeaterSync")
+ @patch(f"{MODULE}.repartition_table_in_place", new_callable=AsyncMock)
+ @patch(f"{MODULE}.DeltaTableRef")
+ @patch(f"{MODULE}.is_auto_repartition_enabled", return_value=True)
+ @patch(f"{MODULE}.ExternalDataJob")
+ @patch(f"{MODULE}.ExternalDataSchema")
+ def test_bare_nosuchkey_stands_down_without_burning_an_attempt(
+ self,
+ mock_schema_model: MagicMock,
+ _mock_job_model: MagicMock,
+ _mock_enabled: MagicMock,
+ _mock_helper_cls: MagicMock,
+ mock_repartition: AsyncMock,
+ _mock_heartbeater: MagicMock,
+ mock_capture_event: MagicMock,
+ _mock_capture_exception: MagicMock,
+ ) -> None:
+ # A pathless S3 NoSuchKey from an s3fs purge/swap op that raced a concurrent delete is a
+ # transient object-store blip, not a repartition bug: it must not emit a failure event or
+ # consume one of the table's finite attempts, so the next sync simply retries.
+ schema = _schema(name="public.usages", s3_folder_name="usages", pending={**PENDING_TARGET, "attempts": 0})
+ mock_schema_model.objects.select_related.return_value.get.return_value = schema
+ mock_repartition.side_effect = FileNotFoundError("The specified key does not exist.")
+
+ _maybe_repartition_table(
+ RepartitionActivityInputs(team_id=TEAM_ID, schema_id=SCHEMA_ID, job_id=JOB_ID, source_id=SOURCE_ID),
+ MagicMock(),
+ )
+
+ emitted = [c.args[0] for c in mock_capture_event.call_args_list]
+ assert "warehouse_repartition_failed" not in emitted
+ schema.set_repartition_pending.assert_not_called()
+ schema.clear_repartition_pending.assert_not_called()
+
+
class TestFeatureFlagGate:
@parameterized.expand(
[