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): stop tracking a transient object-store blip on delta writes as a bug (#108955)

Tom Owersa7902fe780fb
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/ops.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/ops.py
index 03dac2860db3..6ca82a93c9f7 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/ops.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/ops.py
@@ -11,8 +11,10 @@ from structlog.types import FilteringBoundLogger
from posthog.exceptions_capture import capture_exception
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (
+ TransientObjectStoreError,
is_invalid_version_race,
is_transient_maintenance_error,
+ is_transient_object_store_error,
)
T = TypeVar("T")
@@ -44,6 +46,13 @@ OBJECT_STORE_PERMISSION_DENIED_MESSAGE = (
"PostHog's side, not with your source. Contact support if it keeps happening."
)
+# Same reasoning as OBJECT_STORE_PERMISSION_DENIED_MESSAGE: this is what a customer reads if every
+# retry is exhausted, so it names neither the bucket nor the object key either.
+OBJECT_STORE_TRANSIENT_MESSAGE = (
+ "PostHog hit a temporary problem reading or writing this table's files in its own storage. "
+ "The next scheduled run will try again."
+)
+
class ObjectStorePermissionDeniedError(Exception):
"""The data warehouse bucket refused a read, a write or a delete.
@@ -122,6 +131,15 @@ async def execute_with_conflict_retry(
# tells which layer translated the refusal, without repeating the key.
await logger.awarning(f"{operation_name}: the object store denied the operation ({type(e).__name__})")
raise ObjectStorePermissionDeniedError(OBJECT_STORE_PERMISSION_DENIED_MESSAGE) from e
+ if is_transient_object_store_error(e):
+ # Same blip get_delta_table already classifies (see table.py's
+ # _capture_unless_transient) - a bare re-raise here would still mint a fresh
+ # error-tracking issue at the activity boundary, and burn the conflict-retry budget
+ # on a call that isn't a commit conflict. The raw text (kept only on __cause__) can
+ # name the bucket and the object key, so the wrapper's own message stays generic in
+ # case every retry is exhausted and it reaches the customer as the sync's error text.
+ await logger.awarning(f"{operation_name}: transient object-store error, not reporting: {e}")
+ raise TransientObjectStoreError(OBJECT_STORE_TRANSIENT_MESSAGE) from e
if not isinstance(e, deltalake.exceptions.DeltaError):
raise
if not isinstance(e, deltalake.exceptions.CommitFailedError) and not is_invalid_version_race(e):
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_ops.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_ops.py
index 749d8d4acdfc..8a9f4577ad94 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_ops.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/core/delta/test/test_ops.py
@@ -6,6 +6,9 @@ from django.test import override_settings
import deltalake
from parameterized import parameterized
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.errors import (
+ TransientObjectStoreError,
+)
from products.warehouse_sources.backend.temporal.data_imports.pipelines.core.delta.ops import (
DELTA_MERGE_CONFLICT_RETRIES,
ObjectStorePermissionDeniedError,
@@ -133,6 +136,31 @@ class TestExecuteWithConflictRetry:
operation_fn.assert_called_once()
table.update_incremental.assert_not_called()
+ @pytest.mark.asyncio
+ async def test_transient_object_store_error_is_wrapped_and_not_retried(self):
+ # delta-rs prefixes a self-recovering object-store blip (e.g. the backend refusing a PUT
+ # because it's temporarily out of free space) with "Generic S3 error". Regression coverage
+ # for this reaching the caller as a raw DeltaError, which the activity boundary would report
+ # as a fresh error-tracking issue per write and would leak into the customer-facing error,
+ # instead of the same non-reportable classification get_delta_table already applies.
+ table = MagicMock()
+ error = deltalake.exceptions.DeltaError(
+ "Failed to parse parquet: External: Generic S3 error: Error performing PUT "
+ "in 5s, after 10 retries - Server returned non-2xx status code: 507 Insufficient Storage"
+ )
+ operation_fn = MagicMock(side_effect=error)
+
+ with pytest.raises(TransientObjectStoreError) as exc_info:
+ await execute_with_conflict_retry(table, operation_fn, "op", make_logger())
+
+ assert exc_info.value.__cause__ is error
+ # This can reach the customer as the sync run's error text if every retry is exhausted, so
+ # the raw storage text (which can name the bucket and the object key) must not survive into
+ # the wrapper's own message - only onto __cause__, asserted above.
+ assert "Insufficient Storage" not in str(exc_info.value)
+ operation_fn.assert_called_once()
+ table.update_incremental.assert_not_called()
+
@parameterized.expand(
[
# delta-rs maps a 403 from its Rust object_store crate onto io::ErrorKind::PermissionDenied