Skip to content

chore(warehouse-sources): route v2 pipeline post-load through shared orchestrator - #74746

Merged
trunk-io[bot] merged 3 commits into
masterfrom
posthog-code/v2-post-load-route
Jul 30, 2026
Merged

chore(warehouse-sources): route v2 pipeline post-load through shared orchestrator#74746
trunk-io[bot] merged 3 commits into
masterfrom
posthog-code/v2-post-load-route

Conversation

@estefaniarabadan

@estefaniarabadan estefaniarabadan commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Problem

The v2 pipeline's _post_run_operations carried an inline copy of the shared post-load sequence in pipelines/common/load.py — compaction, S3 publishing, sync bookkeeping, table validation, CDC companion seeding, view syncing. Every fix had to be written twice: #74630 is a recent example, patching the same transient-S3 handling in both copies in one PR. And the shared orchestrator itself still mixed the core publish/register flow with CDC-specific branching and product side effects.

This is part 2 of 2 of the post-load unification (following #74671). With this change, pipelines/common/ has a single post-load implementation used by both pipeline versions and CDC companion seeding, with the CDC-specific logic and product side effects behind their own seams.

Changes

Commit 1 — route v2 through the shared orchestrator:

PipelineNonDLT._post_run_operations is now a thin wrapper calling run_post_load_operations, forwarding the resource and last incremental value (so desc-sort cursor finalization keeps working) and returning the orchestrator's queryable folder (so ducklake's prepared_queryable_folder keeps flowing). The ~95-line duplicated block and six now-unused imports are deleted. The wrapper stays a method because the e2e tests patch.object it as a seam.

Commit 2 — finish the orchestrator's step shape:

  • _register_tables_and_seed is split into _register_table (plain table validation/registration) and _run_cdc_post_load (companion registration + snapshot seeding), the latter invoked only for CDC schemas and companion writes — so the non-CDC path no longer routes through CDC branching.
  • The revenue-ready notification, revenue/engineering analytics view syncs, and repartition detection move into POST_LOAD_STEPS, a tuple of callables sharing one PostLoadStep protocol signature. This is the seam where product hooks can later register post-load side effects (following the external_product_hooks.py pattern) instead of editing this module.

Note

Behavior deltas, each aligning v2 with what v3 already does or reordering independent operations:

  • v2's CDC-snapshot runs get threshold-based delta maintenance instead of unconditional compaction
  • v2 gains post-load repartition detection (feature-flag gated, never raises) and post-load duration metrics
  • v2's existing_queryable_folder is read live from schema.table instead of the pipeline-start snapshot (fresher, and correct when partial loading created the table mid-run)
  • the revenue-ready notification now runs after table registration instead of between last_synced_at and initial_sync_complete (the operations are independent)
  • the cdc_seed_check info log no longer fires for non-CDC schemas

How did you test this code?

  • pipelines/pipeline_v2/ + pipelines/common/: all passing after each commit (43 and 41+15 respectively)
  • Repo-wide uv run mypy --cache-fine-grained .: no issues in 17,083 files
  • ruff check / ruff format: clean

Test changes: deleted TestPostRunOperationsCompactionErrorHandling — it exercised the deleted duplicated block, and the same regressions (transient S3 blip vs genuine failure, for both the compact and maintenance paths) are covered by pipelines/common/test/test_load.py. Added one test asserting the wrapper returns the orchestrator's queryable folder and forwards resource/last_incremental_field_value — that regression is otherwise silent: ducklake registration reads the result with .get(...), desc-sort finalization just skips, and every e2e test mocks _post_run_operations, so no existing test would notice. The commit-2 restructure adds no new branches, so no new tests.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No user-facing or documented-workflow changes.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Authored with Claude Code as phase 2 (part 2 of 2) of the warehouse pipelines separation plan, continuing #74352 and #74671. Skills invoked: /writing-tests (gating the test deletion and the one new test). Verification: repo-wide mypy, targeted hogli test runs, ruff. Decisions: kept _post_run_operations as a method rather than inlining into run() because the e2e suite patches it via patch.object; POST_LOAD_STEPS is a plain module-level tuple rather than a registry — the registration mechanism is deliberately out of scope per the plan, this commit only shapes the entries to a shared signature; the behavior deltas listed above were accepted deliberately rather than parameterized away, since each matches the v3 path the orchestrator already serves.

…orchestrator

Replace PipelineNonDLT._post_run_operations' inline copy of the post-load sequence with a call to run_post_load_operations, deleting the duplicated compaction, S3 publishing, bookkeeping, table validation, CDC seeding, and view-sync code. The wrapper stays as a method because the e2e tests patch it.

Behavior deltas for the v2 pipeline, all aligning it with v3:
- CDC-snapshot runs get threshold-based delta maintenance instead of unconditional compaction
- gains post-load repartition detection (feature-flag gated) and post-load duration metrics
- existing_queryable_folder is read live from schema.table instead of the pipeline-start snapshot
- revenue-ready notification now runs before initial_sync_complete is set (independent operations)

The duplicated-block error-handling tests are covered by pipelines/common/test/test_load.py; a new test guards the wrapper's return value and forwarded kwargs, which every e2e test mocks past.
@estefaniarabadan estefaniarabadan self-assigned this Jul 29, 2026
@trunk-io

trunk-io Bot commented Jul 29, 2026

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @estefaniarabadan! 👋

It looks like your git author email on this PR isn't your @posthog.com address (estefania.rabadan@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. 🙂

@estefaniarabadan
estefaniarabadan marked this pull request as ready for review July 29, 2026 14:24
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 29, 2026 14:25
@greptile-apps

greptile-apps Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore(warehouse-sources): route v2 pipel..." | Re-trigger Greptile

@danielcarletti danielcarletti left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

YES

@estefaniarabadan
estefaniarabadan requested a review from a team July 29, 2026 14:46
@estefaniarabadan

Copy link
Copy Markdown
Contributor Author

/trunk merge

estefaniarabadan and others added 2 commits July 29, 2026 18:25
…ep list

Finish the phase-2 step shape for run_post_load_operations:

- Split _register_tables_and_seed into _register_table (plain table validation) and _run_cdc_post_load (companion registration + snapshot seeding), the latter invoked only for CDC schemas and companion writes.
- Move the revenue-ready notification, revenue/engineering analytics view syncs, and repartition detection into POST_LOAD_STEPS, a list of callables sharing one PostLoadStep signature — the future registration point for product hooks.

Behavior-neutral except: the revenue-ready notification now runs after table registration instead of between last_synced_at and initial_sync_complete (independent operations), and the cdc_seed_check info log no longer fires for non-CDC schemas.
@trunk-io
trunk-io Bot merged commit 2cc80c5 into master Jul 30, 2026
232 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/v2-post-load-route branch July 30, 2026 11:10
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 30, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-30 11:59 UTC Run
prod-us ✅ Deployed 2026-07-30 12:17 UTC Run
prod-eu ✅ Deployed 2026-07-30 12:22 UTC Run

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants