Skip to content

fix(data-imports): stop reporting transient S3 blips as compaction failures - #74630

Merged
trunk-io[bot] merged 1 commit into
masterfrom
posthog-code/fix-vacuum-post-run-transient-s3-noise
Jul 29, 2026
Merged

fix(data-imports): stop reporting transient S3 blips as compaction failures#74630
trunk-io[bot] merged 1 commit into
masterfrom
posthog-code/fix-vacuum-post-run-transient-s3-noise

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

Problem

An error tracking issue surfaced an OSError: Generic S3 error ... 503 Service Unavailable ... SlowDown ... Please reduce your request rate, raised from DeltaTableHelper.vacuum_table() (via compact_table()), called from _post_run_operations() at the end of every v2-pipeline sync. The same fingerprint fires across many unrelated source types and schemas within the same short window, which points at S3 throttling a burst of concurrent post-sync vacuum/compact operations against the shared data-warehouse bucket, not a bug tied to any one source.

Tracing the call site: _post_run_operations already wraps compact_table() in a bare try/except Exception: capture_exception(e) — so the sync itself is unaffected either way, this is purely error-tracking noise. The pipeline layer already has a classifier for exactly this failure mode, is_transient_object_store_error() in delta_table_helper.py, and the pre-write maintenance path (common/extract.py's run_pre_write_defensive_compact) already uses it to log a warning instead of capturing. The post-run path in pipeline_v2/pipeline.py, and the equivalent post-load paths in common/load.py (CDC maintenance and non-CDC compact), never picked it up, so the exact same transient S3 blip is treated inconsistently depending on which call site hits it.

Changes

  • pipeline_v2/pipeline.py's _post_run_operations: check is_transient_object_store_error(e) before capturing a compact_table() failure; log a warning instead when it's a recognized transient S3 blip.
  • common/load.py's run_post_load_operations: same treatment for both the CDC run_maintenance() branch and the non-CDC compact_table() branch.

No retry policy, timeout, or NonRetryableErrors classification changed — this only makes an already-non-fatal exception path consistent with the classifier the pipeline already has, at the two call sites that were missing it.

How did you test this code?

  • Extended pipeline_v2/test/test_pipeline.py with a parameterized test_compaction_error_handling (transient S3 blip → warning, no capture; genuine OSError → captured) — the exact regression this PR fixes.
  • Extended common/test/test_load.py's TestRunPostLoadDeltaMaintenance similarly for both the CDC maintenance path and the non-CDC compact path.
  • Ran the full test_pipeline.py (pipeline_v2), test_load.py (common), and test_delta_table_helper.py (core) suites: 82 passed, 4 pre-existing failures in TestGetDeltaTableUnrecoverableErrors that need a live object-storage service unavailable in this sandbox — confirmed identical on unmodified master.
  • ruff check / ruff format --check clean on all 4 changed files.
  • Full-repo uv run mypy --cache-fine-grained . clean (17074 source files).

Docs update

N/A — internal pipeline implementation detail, no user-facing or API surface change.

🤖 Agent context

Autonomy: Fully autonomous

Triaged from a live PostHog error-tracking issue (webhook-delivered) using Claude Code. Pulled the stack trace, exception samples, and warehouse_sources_* properties via the PostHog MCP tools to confirm the failure is cross-source (Postgres, MySQL, GoogleAds, GitHub) and lives entirely in shared pipeline code. Searched open PRs for duplicates: found #69306 addressing the same root cause with a similar design, but it targets pipelines/pipeline/delta_table_helper.py, a path removed by a since-refactor (now pipelines/core/), so it can't land as-is; also checked #74541 (a different bug in the same file) for overlap — none. Invoked /writing-tests before adding test coverage.

…ilures

Applies the existing `is_transient_object_store_error` classifier (already used in `common/extract.py`'s pre-write maintenance path) to the two post-run compaction/vacuum call sites that were missing it: `_post_run_operations` in `pipeline_v2/pipeline.py`, and both branches of `run_post_load_operations` in `common/load.py`. All three sites already swallow the exception and let the sync complete either way; the only change is skipping `capture_exception` when the error is a recognized transient S3 blip.

Branch: posthog-code/fix-vacuum-post-run-transient-s3-noise

Generated-By: PostHog Code
Task-Id: 2e3670ef-30aa-4461-995e-ddadf81ee399
@trunk-io

trunk-io Bot commented Jul 29, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Gilbert09! 👋

It looks like your git author email on this PR isn't your @posthog.com address (owerstom@gmail.com). Since you're on the PostHog team, it's worth pointing your local git author email at your @posthog.com address. Why it matters:

  • Consistent work identity in git history — internal tooling that attributes commits to team members keys off your @posthog.com address.
  • Keeps team contributions easy to tell apart from external community ones when scanning history.

You can fix it for this repo with:

git config user.email "you@posthog.com"

Or set it globally with git config --global user.email "you@posthog.com". No need to redo this PR — just a nudge for next time. 🙂

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 29, 2026 11:30
@Gilbert09 Gilbert09 added the stamphog Request AI approval (no full review) label Jul 29, 2026 — with PostHog

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Contained fix that only changes error-tracking noise classification for an already-caught, non-fatal exception path (no behavior/retry change), with regression tests covering both branches; author is on the owning team.

  • Author wrote 0% of the modified lines and has 11 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 33L, 2F substantive, 141L/4F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1c-medium (141L, 4F, single-area, fix)
stamphog 2.0.0b3 .stamphog/policy.yml @ 545937f · reviewed head c196c13

@talyn-app

talyn-app Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

/trunk merge

@trunk-io
trunk-io Bot merged commit aed559b into master Jul 29, 2026
367 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/fix-vacuum-post-run-transient-s3-noise branch July 29, 2026 13:03
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 29, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-29 14:33 UTC Run
prod-us ✅ Deployed 2026-07-29 14:46 UTC Run
prod-eu ✅ Deployed 2026-07-29 14:49 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant