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(property-vals): bump kafka_num_consumers to 8 on property_values (#59955)

Andy Zhaoa2e7ef01412f
diff --git a/posthog/clickhouse/migrations/0268_property_values_kafka_num_consumers.py b/posthog/clickhouse/migrations/0268_property_values_kafka_num_consumers.py
new file mode 100644
index 000000000000..d2c44c710322
--- /dev/null
+++ b/posthog/clickhouse/migrations/0268_property_values_kafka_num_consumers.py
@@ -0,0 +1,39 @@
+from posthog import settings
+from posthog.clickhouse.client.connection import NodeRole
+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions
+from posthog.clickhouse.property_values import (
+ DROP_KAFKA_PROPERTY_VALUES_TABLE_SQL,
+ DROP_PROPERTY_VALUES_MV_SQL,
+ KAFKA_PROPERTY_VALUES_TABLE_SQL_FN,
+ PROPERTY_VALUES_MV_SQL,
+)
+
+if settings.CLOUD_DEPLOYMENT in ("US", "EU"):
+ _ROLES = [NodeRole.AUX]
+elif settings.CLOUD_DEPLOYMENT == "DEV":
+ _ROLES = [NodeRole.DATA]
+else:
+ _ROLES = []
+
+operations = (
+ [
+ run_sql_with_exceptions(
+ DROP_PROPERTY_VALUES_MV_SQL(),
+ node_roles=_ROLES,
+ ),
+ run_sql_with_exceptions(
+ DROP_KAFKA_PROPERTY_VALUES_TABLE_SQL(),
+ node_roles=_ROLES,
+ ),
+ run_sql_with_exceptions(
+ KAFKA_PROPERTY_VALUES_TABLE_SQL_FN(),
+ node_roles=_ROLES,
+ ),
+ run_sql_with_exceptions(
+ PROPERTY_VALUES_MV_SQL(),
+ node_roles=_ROLES,
+ ),
+ ]
+ if _ROLES
+ else []
+)
diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txt
index 7828d5bf93f7..afa2bebe439c 100644
--- a/posthog/clickhouse/migrations/max_migration.txt
+++ b/posthog/clickhouse/migrations/max_migration.txt
@@ -1 +1 @@
-0267_wire_up_existing_dmat_string_columns
+0268_property_values_kafka_num_consumers
diff --git a/posthog/clickhouse/property_values.py b/posthog/clickhouse/property_values.py
index 47aac16d955b..fbb3e3033ce3 100644
--- a/posthog/clickhouse/property_values.py
+++ b/posthog/clickhouse/property_values.py
@@ -21,6 +21,7 @@ CREATE TABLE IF NOT EXISTS {table_name}
`property_value` String,
`property_count` UInt64
) ENGINE = {engine}
+SETTINGS kafka_num_consumers = 8, kafka_thread_per_consumer = 1
"""
PROPERTY_VALUES_TABLE_BASE_SQL = """
diff --git a/posthog/clickhouse/test/__snapshots__/test_schema.ambr b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
index 061cc64e6d5c..9a2afc30ebd8 100644
--- a/posthog/clickhouse/test/__snapshots__/test_schema.ambr
+++ b/posthog/clickhouse/test/__snapshots__/test_schema.ambr
@@ -577,6 +577,7 @@
`property_value` String,
`property_count` UInt64
) ENGINE = Kafka(warpstream_ingestion, kafka_topic_list = 'clickhouse_property_values_test', kafka_group_name = 'clickhouse_property_values', kafka_format = 'JSONEachRow')
+ SETTINGS kafka_num_consumers = 8, kafka_thread_per_consumer = 1
'''
# ---
@@ -2436,6 +2437,7 @@
`property_value` String,
`property_count` UInt64
) ENGINE = Kafka(warpstream_ingestion, kafka_topic_list = 'clickhouse_property_values_test', kafka_group_name = 'clickhouse_property_values', kafka_format = 'JSONEachRow')
+ SETTINGS kafka_num_consumers = 8, kafka_thread_per_consumer = 1
'''
# ---