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.

fix(clickhouse): handle missing posthog_instancesetting table during migrations (#59873)

Paweł Szczur27f1e35c8c6e
diff --git a/posthog/clickhouse/client/execute.py b/posthog/clickhouse/client/execute.py
index 541ab6015b43..8965ecf7493b 100644
--- a/posthog/clickhouse/client/execute.py
+++ b/posthog/clickhouse/client/execute.py
@@ -147,17 +147,21 @@ def get_hedged_app_queries_enabled() -> bool:
def _get_hedged_app_queries_enabled(_ttl: int) -> bool:
from posthog.models.instance_setting import get_instance_setting
- return get_instance_setting("CLICKHOUSE_HEDGED_APP_QUERIES")
+ try:
+ return get_instance_setting("CLICKHOUSE_HEDGED_APP_QUERIES")
+ except Exception:
+ return False
@lru_cache(maxsize=1)
def _get_kill_switch_level(_ttl: int) -> KillSwitchLevel:
from posthog.models.instance_setting import get_instance_setting
- value = get_instance_setting("CLICKHOUSE_KILL_SWITCH")
try:
+ value = get_instance_setting("CLICKHOUSE_KILL_SWITCH")
return KillSwitchLevel(value)
- except ValueError:
+ except Exception:
+ # posthog_instancesetting may not exist yet during initial Postgres migrations
return KillSwitchLevel.OFF