Skip to content

chore(clickhouse): drop precalculated warpstream kafka engine tables - #79807

Merged
trunk-io[bot] merged 5 commits into
masterfrom
posthog-code/drop-warpstream-calculated-events-kafka-engines
Aug 27, 2026
Merged

trunk-io[bot] merged 5 commits into
masterfrom
posthog-code/drop-warpstream-calculated-events-kafka-engines

Conversation

@gustavohstrassburger

@gustavohstrassburger gustavohstrassburger commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Nobody can decommission the warpstream-calculated-events cluster while ClickHouse still holds Kafka engine tables against it. Those tables serve no one: both precalculated topics lost their producers, so the four objects reading them consume nothing.

They cannot just be left behind. A Kafka engine table whose named collection has been removed from the ClickHouse config error-loops on every poll, so the tables have to go before the collection does.

Changes

Drops the Kafka engine table and its materialized view for each of the two precalculated topics.

Topic Kafka engine table
clickhouse_prefiltered_events kafka_precalculated_events_ws
clickhouse_precalculated_person_properties kafka_precalculated_person_properties_ws

Within each pair the materialized view is dropped first, so it stops feeding its writable table before the Kafka table disappears.

Both drops are unconditional, because 0229 created both pairs unconditionally. 0243 later dropped the events pair everywhere and recreated it cloud-only, since off-cloud warpstream_calculated_events resolves to the same brokers as msk_cluster and the pair double-writes. That migration left kafka_precalculated_person_properties_ws behind, which this drop finally removes. Every statement is DROP TABLE IF EXISTS, so the migration is idempotent either way.

kafka_cohort_membership_ws reads from the same collection but stays. It is dropped separately, so its removal lands with the cohort work that owns it rather than inside a migration about precalculated tables.

Data tables are untouched. precalculated_events and precalculated_person_properties both stay, as do the MSK-fed Kafka tables, which resolve a different named collection and are unaffected by this cluster going away.

How did you test this code?

  • hogli ci:preflight --strict on the push: ruff lint, ruff format, and the migration conflict check all pass.
  • Confirmed all four imported DROP_*_SQL helpers exist on master, so the migration needs no model change.

Not done: the migration was never run against a real ClickHouse, and no automated test exercises it.

Automatic notifications

  • Publish to changelog?

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Authored with Claude Code (PostHog Code). Skills invoked: /clickhouse-migrations for the original migration, /writing-pr-descriptions for this body. Also read posthog/clickhouse/migrations/AGENTS.md for the node-role and guard conventions.

The migration started as cohort-membership-only, widened to all three topics on the same named collection, then narrowed to the two precalculated pairs so the cohort drop can ship on its own schedule.

Kept migration-only per AGENTS.md. The matching consumer removal is a separate PR, and the now-unused SQL builders stay in place so no already-applied migration needs rewriting.

Part of a cross-repo decommission, with companion PRs in PostHog/charts and posthog-cloud-infra. This one is safe to land first and independently.

@trunk-io

trunk-io Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "chore(cohorts): drop warpstream-calculat..." | Re-trigger Greptile

@github-actions

github-actions Bot commented Aug 7, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

⚠️ Playwright — 1 failed

🎭 Playwright report · View test results →

❌ 1 failed test:

  • Hover chart to see tooltip with data point values (chromium)

These issues are not necessarily caused by your changes.
Annoyed by this section? Help fix flakies and failures and it will go green!

⚠️ Backend snapshots — 1 updated (1 modified, 0 added, 0 deleted)

Query snapshots: Backend query snapshots updated

Changes: 1 snapshots (1 modified, 0 added, 0 deleted)

What this means:

  • Query snapshots have been automatically updated to match current output
  • These changes reflect modifications to database queries or schema

Next steps:

  • Review the query changes to ensure they're intentional
  • If unexpected, investigate what caused the query to change

Review snapshot changes →

ℹ️ ClickHouse migration SQL — 1 migration(s)

ClickHouse migration SQL per cloud environment

  • unset
    • all
      DROP TABLE IF EXISTS precalculated_events_ws_mv
      DROP TABLE IF EXISTS kafka_precalculated_events_ws
      DROP TABLE IF EXISTS precalculated_person_properties_ws_mv
      DROP TABLE IF EXISTS kafka_precalculated_person_properties_ws
  • US, EU, DEV
    • medium
      DROP TABLE IF EXISTS precalculated_events_ws_mv
      DROP TABLE IF EXISTS kafka_precalculated_events_ws
      DROP TABLE IF EXISTS precalculated_person_properties_ws_mv
      DROP TABLE IF EXISTS kafka_precalculated_person_properties_ws

@trunk-io

trunk-io Bot commented Aug 7, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@haacked haacked moved this to Todo in Feature Flags Aug 10, 2026
@gustavohstrassburger
gustavohstrassburger force-pushed the posthog-code/drop-warpstream-calculated-events-kafka-engines branch 2 times, most recently from a275685 to 485db5f Compare August 11, 2026 17:23
@gustavohstrassburger
gustavohstrassburger marked this pull request as ready for review August 11, 2026 19:46
@gustavohstrassburger
gustavohstrassburger requested a review from a team as a code owner August 11, 2026 19:46
Copilot AI lite review requested due to automatic review settings August 11, 2026 19:46
@gustavohstrassburger
gustavohstrassburger marked this pull request as draft August 11, 2026 19:47
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Reviews (2): Last reviewed commit: "chore(cohorts): drop warpstream-calculat..." | Re-trigger Greptile

Copilot AI 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.

Pull request overview

Drops ClickHouse Kafka engine tables and their materialized views that point at the warpstream_calculated_events named collection, so the warpstream-calculated-events WarpStream cluster can be decommissioned without Kafka-engine poll error loops.

Changes:

  • Add ClickHouse migration 0296 to drop the two precalculated _ws Kafka/MV pairs unconditionally, and the cohort-membership _ws pair behind the same cloud-only guard used when creating it.
  • Update max_migration.txt to point to the new migration.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
posthog/clickhouse/migrations/max_migration.txt Bumps ClickHouse migration pointer to 0296_*.
posthog/clickhouse/migrations/0296_drop_warpstream_calculated_events_kafka_engines.py Drops WarpStream-calculated-events Kafka engine tables and MVs (MV-first ordering; cloud guard preserved for cohort membership).

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +58 to +66
else [
run_sql_with_exceptions(
"DROP TABLE IF EXISTS cohort_membership_ws_mv",
node_roles=[NodeRole.INGESTION_MEDIUM],
),
run_sql_with_exceptions(
"DROP TABLE IF EXISTS kafka_cohort_membership_ws",
node_roles=[NodeRole.INGESTION_MEDIUM],
),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch — fixed in 361df20. Switched both to DROP_COHORT_MEMBERSHIP_WS_MV_SQL() / DROP_COHORT_MEMBERSHIP_WS_KAFKA_TABLE_SQL().

The emitted SQL is byte-identical, so no behaviour change, and it now mirrors migration 0245 which created these objects using the same module.

@gustavohstrassburger
gustavohstrassburger force-pushed the posthog-code/drop-warpstream-calculated-events-kafka-engines branch from 485db5f to 0df5491 Compare August 11, 2026 20:09
@gustavohstrassburger
gustavohstrassburger marked this pull request as ready for review August 11, 2026 20:09
@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Reviews (3): Last reviewed commit: "chore(cohorts): drop warpstream-calculat..." | Re-trigger Greptile

@gustavohstrassburger

Copy link
Copy Markdown
Contributor Author

@greptile review

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Reviews (4): Last reviewed commit: "chore(cohorts): use shared cohort member..." | Re-trigger Greptile

@gustavohstrassburger gustavohstrassburger moved this from Todo to In Review in Feature Flags Aug 11, 2026

@haacked haacked 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.

Looks good. The drop set is complete and nothing on master reads these objects. One non-blocking suggestion inline.

One thing for the companion infra PR rather than this one: 0229 creates its WS Kafka tables unconditionally and hard-depends on the warpstream_calculated_events named collection, so once that collection leaves an environment's config, a fresh bootstrap replaying migrations from zero fails at 0229. That's pre-existing on master, but worth timing the collection removal around.

@gustavohstrassburger
gustavohstrassburger force-pushed the posthog-code/drop-warpstream-calculated-events-kafka-engines branch from ab0e113 to da2d825 Compare August 12, 2026 21:03
@gustavohstrassburger

Copy link
Copy Markdown
Contributor Author

hey @PostHog/clickhouse, can I get a stamp here please?

@gustavohstrassburger

Copy link
Copy Markdown
Contributor Author

hey @rorylshanks, since you were involved in this, do you mind giving this a look?

@gustavohstrassburger gustavohstrassburger changed the title chore(cohorts): drop warpstream-calculated-events kafka engine tables chore(clickhouse): drop precalculated warpstream kafka engine tables Aug 26, 2026
@github-project-automation github-project-automation Bot moved this from In Review to Approved in Feature Flags Aug 27, 2026
@gustavohstrassburger
gustavohstrassburger force-pushed the posthog-code/drop-warpstream-calculated-events-kafka-engines branch from 7e42a7a to 2f7ae8f Compare August 27, 2026 13:22
tests-posthog Bot and others added 3 commits August 27, 2026 13:40
The migration drops kafka_precalculated_person_properties_ws and its MV,
but the HCL still declared them, so the convergence gate saw the migrated
cluster diverge from the golden schema.

Removes both from the ingestion_medium local layer and regenerates
golden/ and sql/. Only the local goldens move: the events pair is already
absent off-cloud, so nothing else in the composition changes.

Generated-By: PostHog Desktop
Task-Id: 6664f40e-4d5f-4818-89a8-b9ebdcefc718
@gustavohstrassburger

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit 06cf6d7 into master Aug 27, 2026
240 checks passed
@trunk-io
trunk-io Bot deleted the posthog-code/drop-warpstream-calculated-events-kafka-engines branch August 27, 2026 19:16
@github-project-automation github-project-automation Bot moved this from Approved to Done in Feature Flags Aug 27, 2026
@deployment-status-posthog

deployment-status-posthog Bot commented Aug 27, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-08-27 20:23 UTC Run
prod-us ✅ Deployed 2026-08-27 20:45 UTC Run
prod-eu ✅ Deployed 2026-08-28 07:22 UTC Run

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

Labels

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants