: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
chore(ml/replay): Recreate session replay features tables from clean slate (#59045)
Nicholas Waltzbdce7afc256f
diff --git a/posthog/clickhouse/migrations/0266_recreate_session_replay_features.py b/posthog/clickhouse/migrations/0266_recreate_session_replay_features.pynew file mode 100644index 000000000000..b7a39455d682--- /dev/null+++ b/posthog/clickhouse/migrations/0266_recreate_session_replay_features.py@@ -0,0 +1,64 @@+from posthog import settings+from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions+from posthog.session_recordings.sql.session_replay_feature_sql import (+ DISTRIBUTED_SESSION_REPLAY_FEATURES_TABLE_SQL,+ KAFKA_SESSION_REPLAY_FEATURES_TABLE_SQL,+ KAFKA_SESSION_REPLAY_FEATURES_WS_TABLE_SQL,+ SESSION_REPLAY_FEATURES_TABLE_MV_SQL,+ SESSION_REPLAY_FEATURES_TABLE_SQL,+ SESSION_REPLAY_FEATURES_WS_MV_SQL,+ WRITABLE_SESSION_REPLAY_FEATURES_TABLE_SQL,+)++# Recreate session_replay_features from scratch.++_is_cloud = settings.CLOUD_DEPLOYMENT in ("US", "EU", "DEV")++operations = [+ # 1. Sharded storage on AUX.+ run_sql_with_exceptions(+ SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False),+ node_roles=[NodeRole.AUX],+ ),+ # 2. Read-side Distributed on AUX.+ run_sql_with_exceptions(+ DISTRIBUTED_SESSION_REPLAY_FEATURES_TABLE_SQL(+ on_cluster=False,+ cluster=settings.CLICKHOUSE_AUX_CLUSTER,+ ),+ node_roles=[NodeRole.AUX, NodeRole.DATA],+ ),+ # 3. Writable Distributed on INGESTION_MEDIUM.+ run_sql_with_exceptions(+ WRITABLE_SESSION_REPLAY_FEATURES_TABLE_SQL(+ on_cluster=False,+ cluster=settings.CLICKHOUSE_AUX_CLUSTER,+ ),+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ # 4. Kafka consumer + MV.+ *(+ [+ run_sql_with_exceptions(+ KAFKA_SESSION_REPLAY_FEATURES_WS_TABLE_SQL(),+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ run_sql_with_exceptions(+ SESSION_REPLAY_FEATURES_WS_MV_SQL(),+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ ]+ if _is_cloud+ else [+ run_sql_with_exceptions(+ KAFKA_SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False),+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ run_sql_with_exceptions(+ SESSION_REPLAY_FEATURES_TABLE_MV_SQL(on_cluster=False),+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ ]+ ),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex 2d77ed240330..587b3b87fb3e 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0265_add_surfacing_score_to_session_replay_events+0266_recreate_session_replay_features