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.

feat(cdp): route hog_invocation_results Kafka table to warpstream-cyclotron (#59360)

Ben White3cd2fcdeebd3
diff --git a/docker/clickhouse/config.d/default.xml b/docker/clickhouse/config.d/default.xml
index d559675e86aa..d2fec4ba469e 100644
--- a/docker/clickhouse/config.d/default.xml
+++ b/docker/clickhouse/config.d/default.xml
@@ -93,6 +93,9 @@
<warpstream_shared>
<kafka_broker_list from_env="KAFKA_HOSTS"/>
</warpstream_shared>
+ <warpstream_cyclotron>
+ <kafka_broker_list from_env="KAFKA_HOSTS"/>
+ </warpstream_cyclotron>
</named_collections>
<macros>
diff --git a/docker/clickhouse/config.d/multinode/ai_events_node.xml b/docker/clickhouse/config.d/multinode/ai_events_node.xml
index c12a7aeff3b3..d9d7914a7d95 100644
--- a/docker/clickhouse/config.d/multinode/ai_events_node.xml
+++ b/docker/clickhouse/config.d/multinode/ai_events_node.xml
@@ -118,6 +118,9 @@
<warpstream_shared>
<kafka_broker_list from_env="KAFKA_HOSTS"/>
</warpstream_shared>
+ <warpstream_cyclotron>
+ <kafka_broker_list from_env="KAFKA_HOSTS"/>
+ </warpstream_cyclotron>
</named_collections>
<macros>
diff --git a/docker/clickhouse/config.d/multinode/aux_node.xml b/docker/clickhouse/config.d/multinode/aux_node.xml
index 3c1290fd12c0..c93ca1fb8c3b 100644
--- a/docker/clickhouse/config.d/multinode/aux_node.xml
+++ b/docker/clickhouse/config.d/multinode/aux_node.xml
@@ -118,6 +118,9 @@
<warpstream_shared>
<kafka_broker_list from_env="KAFKA_HOSTS"/>
</warpstream_shared>
+ <warpstream_cyclotron>
+ <kafka_broker_list from_env="KAFKA_HOSTS"/>
+ </warpstream_cyclotron>
</named_collections>
<macros>
diff --git a/docker/clickhouse/config.d/multinode/data_node.xml b/docker/clickhouse/config.d/multinode/data_node.xml
index 630522d2dca9..a2d4b4e1a965 100644
--- a/docker/clickhouse/config.d/multinode/data_node.xml
+++ b/docker/clickhouse/config.d/multinode/data_node.xml
@@ -118,6 +118,9 @@
<warpstream_shared>
<kafka_broker_list from_env="KAFKA_HOSTS"/>
</warpstream_shared>
+ <warpstream_cyclotron>
+ <kafka_broker_list from_env="KAFKA_HOSTS"/>
+ </warpstream_cyclotron>
</named_collections>
<macros>
diff --git a/docker/clickhouse/config.d/multinode/ops_node.xml b/docker/clickhouse/config.d/multinode/ops_node.xml
index 84e7652255bb..ed1ea91c4eca 100644
--- a/docker/clickhouse/config.d/multinode/ops_node.xml
+++ b/docker/clickhouse/config.d/multinode/ops_node.xml
@@ -118,6 +118,9 @@
<warpstream_shared>
<kafka_broker_list from_env="KAFKA_HOSTS"/>
</warpstream_shared>
+ <warpstream_cyclotron>
+ <kafka_broker_list from_env="KAFKA_HOSTS"/>
+ </warpstream_cyclotron>
</named_collections>
<macros>
diff --git a/docker/clickhouse/config.d/multinode/sessions_node.xml b/docker/clickhouse/config.d/multinode/sessions_node.xml
index 800a8a14dbbc..1fc6cda43c87 100644
--- a/docker/clickhouse/config.d/multinode/sessions_node.xml
+++ b/docker/clickhouse/config.d/multinode/sessions_node.xml
@@ -118,6 +118,9 @@
<warpstream_shared>
<kafka_broker_list from_env="KAFKA_HOSTS"/>
</warpstream_shared>
+ <warpstream_cyclotron>
+ <kafka_broker_list from_env="KAFKA_HOSTS"/>
+ </warpstream_cyclotron>
</named_collections>
<macros>
diff --git a/posthog/clickhouse/migrations/0258_hog_invocation_results_warpstream_cyclotron.py b/posthog/clickhouse/migrations/0258_hog_invocation_results_warpstream_cyclotron.py
new file mode 100644
index 000000000000..3628b0f8cc60
--- /dev/null
+++ b/posthog/clickhouse/migrations/0258_hog_invocation_results_warpstream_cyclotron.py
@@ -0,0 +1,35 @@
+from posthog.clickhouse.client.connection import NodeRole
+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
+from posthog.models.hog_invocation_results.sql import (
+ DROP_HOG_INVOCATION_RESULTS_MV_SQL,
+ DROP_KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL,
+ HOG_INVOCATION_RESULTS_MV_SQL,
+ KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL,
+)
+
+# Repoint the hog_invocation_results Kafka engine table from the warpstream-shared
+# named collection to warpstream-cyclotron. The CDP producer writes lifecycle
+# rows to the cyclotron Warpstream cluster, so ClickHouse must consume from the
+# same cluster. The Kafka engine table and MV are non-replicated, so a plain
+# drop + recreate is safe (no SYNC needed); the data table is untouched.
+operations = [
+ # Drop the MV first — it reads from the Kafka engine table.
+ run_sql_with_exceptions(
+ DROP_HOG_INVOCATION_RESULTS_MV_SQL(),
+ node_roles=[NodeRole.AUX],
+ ),
+ # Drop + recreate the Kafka engine table on the warpstream-cyclotron collection.
+ run_sql_with_exceptions(
+ DROP_KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL(),
+ node_roles=[NodeRole.AUX],
+ ),
+ run_sql_with_exceptions(
+ KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL(),
+ node_roles=[NodeRole.AUX],
+ ),
+ # Recreate the MV (kafka -> data table).
+ run_sql_with_exceptions(
+ HOG_INVOCATION_RESULTS_MV_SQL(),
+ node_roles=[NodeRole.AUX],
+ ),
+]
diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txt
index 1474d68af325..7542780a40b0 100644
--- a/posthog/clickhouse/migrations/max_migration.txt
+++ b/posthog/clickhouse/migrations/max_migration.txt
@@ -1 +1 @@
-0257_property_values_count_column
+0258_hog_invocation_results_warpstream_cyclotron
diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
index 62c0a1e4286b..0c9f7bf2f5b9 100644
--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr
+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
@@ -309,7 +309,7 @@
version UInt64,
is_deleted UInt8
)
- ENGINE = Kafka(warpstream_shared, kafka_topic_list = 'clickhouse_hog_invocation_results_test', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_format = 'JSONEachRow')
+ ENGINE = Kafka(warpstream_cyclotron, kafka_topic_list = 'clickhouse_hog_invocation_results_test', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_format = 'JSONEachRow')
SETTINGS kafka_skip_broken_messages = 100
'''
@@ -2136,7 +2136,7 @@
version UInt64,
is_deleted UInt8
)
- ENGINE = Kafka(warpstream_shared, kafka_topic_list = 'clickhouse_hog_invocation_results_test', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_format = 'JSONEachRow')
+ ENGINE = Kafka(warpstream_cyclotron, kafka_topic_list = 'clickhouse_hog_invocation_results_test', kafka_group_name = 'clickhouse_hog_invocation_results', kafka_format = 'JSONEachRow')
SETTINGS kafka_skip_broken_messages = 100
'''
diff --git a/posthog/models/hog_invocation_results/sql.py b/posthog/models/hog_invocation_results/sql.py
index dbff2d09d2e6..06b8dd3f0fc1 100644
--- a/posthog/models/hog_invocation_results/sql.py
+++ b/posthog/models/hog_invocation_results/sql.py
@@ -11,12 +11,12 @@ from posthog.kafka_client.topics import KAFKA_HOG_INVOCATION_RESULTS
HOG_INVOCATION_RESULTS_TTL_DAYS = 30
-# Naming convention mirrors `property_values` — the AUX-resident, non-sharded,
-# WarpStream-shared-consumed table family:
+# Naming convention mirrors `property_values` — the AUX-resident, non-sharded
+# table family:
# * `hog_invocation_results_data` — local replicated table on AUX. Writes flow
# in via the Kafka MV; replay reads happen against the distributed alias.
# * `kafka_hog_invocation_results` — single Kafka engine table on AUX backed
-# by the warpstream-shared named collection.
+# by the warpstream-cyclotron named collection.
# * `hog_invocation_results_mv` — MV on AUX, kafka → data table.
# * `hog_invocation_results` — distributed read alias on AUX + DATA. This is
# the name HogQL emits and the name the replay paginator queries.
@@ -140,7 +140,8 @@ ENGINE = {Distributed(data_table=HOG_INVOCATION_RESULTS_DATA_TABLE, cluster=sett
)
-# Single Kafka pair, backed by the warpstream-shared named collection. We
+# Single Kafka pair, backed by the warpstream-cyclotron named collection — the
+# CDP producer writes lifecycle rows to the cyclotron Warpstream cluster. We
# previously also created an MSK-backed pair alongside this; that's gone — the
# producer writes to one topic and one consumer drains it.
KAFKA_HOG_INVOCATION_RESULTS_TABLE_SQL = lambda: (
@@ -153,7 +154,7 @@ ENGINE = {
kafka_engine(
topic=KAFKA_HOG_INVOCATION_RESULTS,
group=CONSUMER_GROUP_HOG_INVOCATION_RESULTS,
- named_collection=settings.CLICKHOUSE_KAFKA_WARPSTREAM_SHARED_NAMED_COLLECTION,
+ named_collection=settings.CLICKHOUSE_KAFKA_WARPSTREAM_CYCLOTRON_NAMED_COLLECTION,
)
}
SETTINGS kafka_skip_broken_messages = 100
diff --git a/posthog/settings/data_stores.py b/posthog/settings/data_stores.py
index 097ec9433ed2..c9f733a46624 100644
--- a/posthog/settings/data_stores.py
+++ b/posthog/settings/data_stores.py
@@ -356,6 +356,9 @@ CLICKHOUSE_KAFKA_WARPSTREAM_REPLAY_NAMED_COLLECTION: str = os.getenv(
CLICKHOUSE_KAFKA_WARPSTREAM_SHARED_NAMED_COLLECTION: str = os.getenv(
"CLICKHOUSE_KAFKA_WARPSTREAM_SHARED_NAMED_COLLECTION", "warpstream_shared"
)
+CLICKHOUSE_KAFKA_WARPSTREAM_CYCLOTRON_NAMED_COLLECTION: str = os.getenv(
+ "CLICKHOUSE_KAFKA_WARPSTREAM_CYCLOTRON_NAMED_COLLECTION", "warpstream_cyclotron"
+)
# Per-team settings used for client/pool connection parameters. Note that this takes precedence over any workload-based
# routing. Keys should be strings, not numbers.