: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): nuke session replay features tables (#59044)
Nicholas Waltzab36548e3fde
diff --git a/posthog/clickhouse/migrations/0255_nuke_session_replay_features.py b/posthog/clickhouse/migrations/0255_nuke_session_replay_features.pynew file mode 100644index 000000000000..729b25a133b0--- /dev/null+++ b/posthog/clickhouse/migrations/0255_nuke_session_replay_features.py@@ -0,0 +1,40 @@+from posthog.clickhouse.client.connection import NodeRole+from posthog.clickhouse.client.migration_tools import run_sql_with_exceptions++# Tear down session_replay_features end-to-end.++operations = [+ # 1. Materialized views.+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS session_replay_features_mv",+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS session_replay_features_ws_mv",+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ # 2. Kafka consumer tables (MSK + WarpStream).+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS kafka_session_replay_features",+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS kafka_session_replay_features_ws",+ node_roles=[NodeRole.INGESTION_MEDIUM],+ ),+ # 3. writable_session_replay_features Distributed.+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS writable_session_replay_features",+ node_roles=[NodeRole.INGESTION_MEDIUM, NodeRole.DATA],+ ),+ # 4. Read-side Distributed table.+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS session_replay_features",+ node_roles=[NodeRole.AUX, NodeRole.DATA],+ ),+ # 5. Sharded.+ run_sql_with_exceptions(+ "DROP TABLE IF EXISTS sharded_session_replay_features SYNC",+ node_roles=[NodeRole.AUX, NodeRole.DATA],+ ),+]diff --git a/posthog/clickhouse/migrations/max_migration.txt b/posthog/clickhouse/migrations/max_migration.txtindex f34c53584d5f..abfe663c726c 100644--- a/posthog/clickhouse/migrations/max_migration.txt+++ b/posthog/clickhouse/migrations/max_migration.txt@@ -1 +1 @@-0254_hog_invocation_results+0255_nuke_session_replay_featuresdiff --git a/posthog/session_recordings/sql/session_replay_feature_sql.py b/posthog/session_recordings/sql/session_replay_feature_sql.pyindex f8441d9a885e..a28eb753bb5f 100644--- a/posthog/session_recordings/sql/session_replay_feature_sql.py+++ b/posthog/session_recordings/sql/session_replay_feature_sql.py@@ -284,7 +284,7 @@ GROUP BY session_id, team_id"""-def WRITABLE_SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False):+def WRITABLE_SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False, cluster=None):return SESSION_REPLAY_FEATURES_TABLE_BASE_SQL.format(table_name="writable_session_replay_features",uniq_combined_precision=UNIQ_COMBINED_PRECISION,@@ -292,11 +292,12 @@ def WRITABLE_SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False):engine=Distributed(data_table=SESSION_REPLAY_FEATURES_DATA_TABLE(),sharding_key="sipHash64(session_id)",+ cluster=cluster,),)-def DISTRIBUTED_SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False):+def DISTRIBUTED_SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False, cluster=None):return SESSION_REPLAY_FEATURES_TABLE_BASE_SQL.format(table_name="session_replay_features",uniq_combined_precision=UNIQ_COMBINED_PRECISION,@@ -304,6 +305,7 @@ def DISTRIBUTED_SESSION_REPLAY_FEATURES_TABLE_SQL(on_cluster=False):engine=Distributed(data_table=SESSION_REPLAY_FEATURES_DATA_TABLE(),sharding_key="sipHash64(session_id)",+ cluster=cluster,),)