fix(data-imports): retry delta vacuum on commit conflict - #76085
fix(data-imports): retry delta vacuum on commit conflict#76085Gilbert09 wants to merge 1 commit into
Conversation
vacuum() commits a REMOVE of tombstoned files, so it's subject to delta-rs's conflict checker exactly like merge and optimize.compact — but unlike those two, it wasn't routed through execute_with_conflict_retry, so a CommitFailedError from a concurrent maintenance pass propagated straight out instead of retrying with a refreshed table. Generated-By: PostHog Code Task-Id: 20c39f3e-36bf-4381-af67-fb39807aaf94
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
|
Hey @Gilbert09! 👋 It looks like your git author email on this PR isn't your
You can fix it for this repo with: git config user.email "you@posthog.com"Or set it globally with |
🤖 CI report✅ Backend coverage — all changed backend lines covered🧪 Backend test coveragePatch coverage — changed backend lines (products + core): All changed backend lines are covered ✅ Per-product line coverage (touched products)
Report-only. Patch coverage = changed backend lines covered vs |
There was a problem hiding this comment.
Contained internal retry-logic fix for delta-lake vacuum maintenance, author is on the owning team, change is well-tested and generalizes an existing helper already used for compact — no risky territory touched.
- 👍 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 | ✓ | 25L, 2F substantive, 48L/3F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1b-small (48L, 3F, single-area, fix) |
| stamphog 2.0.0b4 | .stamphog/policy.yml @ 34c5044 · reviewed head ccc808c |
Problem
An error tracking issue surfaced a
CommitFailedErrorduring delta maintenance, on the_vacuumframe inmaintenance.py:The call path:
run_scheduled->run_maintenance->compact_if_fragmented->_vacuum-> delta-rs'stable.vacuum().vacuum()commits aREMOVEof tombstoned files, so it's subject to delta-rs's conflict checker exactly likemergeandoptimize.compact— delta-rs doesn't retry this itself (see the comment onDELTA_MERGE_CONFLICT_RETRIES), because resolving it safely means re-reading the table and re-running the operation._compactalready routes throughexecute_with_conflict_retryfor this reason, but_vacuumcalledtable.vacuum()directly, so a concurrent maintenance pass touching the same table (e.g. a second Temporal activity attempt still finishing a compact after the first attempt's heartbeat timed out) made theCommitFailedErrorpropagate straight out instead of retrying with a refreshed table.This is best-effort maintenance code — the exception was already caught by
run_scheduled's try/except and never re-raised, so no sync was ever at risk. This only affects whether a self-healing race gets reported as a defect.Changes
_vacuum'stable.vacuum()call throughexecute_with_conflict_retry, matching_compact.execute_with_conflict_retry's return type (it was typeddict, matchingoptimize.compact()'s stats, butvacuum()returns a list of removed file paths).How did you test this code?
TestVacuum.test_retries_on_commit_conflict_then_succeedsintest_maintenance.py, mirroring the existing compact regression test — asserts_vacuumretries once with a refreshed table onCommitFailedErrorinstead of raising immediately.delta/test/suite (51 tests) andmypy --cache-fine-grainedrepo-wide — both clean.Docs update
N/A — internal maintenance-code fix, 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 and
warehouse_sources_*event properties via the PostHog MCP tools to confirm the failing frame and reproduction context (an Intercom incremental sync), then traced the call path intodelta/maintenance.pyand compared_vacuumagainst_compact's existing conflict-retry handling.Searched open PRs (by exception type, message phrase, module path, and the maintainer's own open PRs) before starting. Found related-but-distinct open/merged work on the same maintenance code (#75240, #73454, #74541, #74594) — all address different
DeltaErrorsignatures or a different re-fetch bug, none add commit-conflict retry to vacuum.