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.

chore(tests): strip ON CLUSTER from TRUNCATEs in the test statement runner (#69440)

Paul D'Ambradd3f2e65749d
diff --git a/posthog/test/base.py b/posthog/test/base.py
index b81e3a5e8adf..038f14b858b5 100644
--- a/posthog/test/base.py
+++ b/posthog/test/base.py
@@ -1598,6 +1598,16 @@ class ClickhouseTestMixin(QueryMatchingTest):
def run_clickhouse_statement_in_parallel(statements: list[str]):
+ # Test infrastructure runs a single-node ClickHouse, so ON CLUSTER only adds
+ # distributed-DDL keeper round-trips (~0.3-0.5s per statement) without changing
+ # the outcome — strip it from TRUNCATEs.
+ # If a CI variant ever runs multi-replica this strip must be removed or gated; without it,
+ # TRUNCATE without ON CLUSTER only touches the connected node and leaves others dirty.
+ statements = [
+ re.sub(r"\s+ON CLUSTER\s+'?[\w-]+'?", "", stmt) if stmt.lstrip().upper().startswith("TRUNCATE") else stmt
+ for stmt in statements
+ ]
+
def _execute_with_retry(stmt: str) -> None:
max_attempts = 5
for attempt in range(max_attempts):