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(clickhouse): multinode gate diagnostics + postgres schema cache (#67506)

Paweł Szczur53d91fc7329a
diff --git a/.github/workflows/ci-clickhouse-multinode-migrations.yml b/.github/workflows/ci-clickhouse-multinode-migrations.yml
index 51dfa0770332..106788404b29 100644
--- a/.github/workflows/ci-clickhouse-multinode-migrations.yml
+++ b/.github/workflows/ci-clickhouse-multinode-migrations.yml
@@ -118,19 +118,20 @@ jobs:
# result and the graceful fallback to `migrate` below.
BASE_SHA=$(git merge-base HEAD^2 "origin/${BASE_REF}" 2>/dev/null || echo "")
fi
- if [ -n "$BASE_SHA" ]; then
- echo "key=posthog-schema-master-${BASE_SHA}" >> "$GITHUB_OUTPUT"
- else
- echo "key=" >> "$GITHUB_OUTPUT"
- echo "::notice::base SHA not found — Postgres schema cache will be skipped"
- fi
+ # Always emit a key so the restore runs; when the exact branch-point
+ # SHA is unknown, the bare prefix lets restore-keys fall back to the
+ # most recent cached master schema (any valid schema works — the smoke
+ # only needs Postgres bootable, migrate_clickhouse doesn't touch it).
+ echo "key=posthog-schema-master-${BASE_SHA}" >> "$GITHUB_OUTPUT"
- name: Restore Postgres schema cache
- if: steps.schema-key.outputs.key != ''
+ if: github.event_name == 'pull_request' || github.event_name == 'merge_group'
uses: actions/cache/restore@cdf6c1fa76f9f475f3d7449005a359c84ca0f306 # v5.0.3
with:
path: schema.sql.gz
key: ${{ steps.schema-key.outputs.key }}
+ restore-keys: |
+ posthog-schema-master-
- name: Log in to ghcr.io
uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3.4.0
diff --git a/posthog/clickhouse/hcl/check-live.sh b/posthog/clickhouse/hcl/check-live.sh
index 09963991a0da..a7d0e4c08db9 100755
--- a/posthog/clickhouse/hcl/check-live.sh
+++ b/posthog/clickhouse/hcl/check-live.sh
@@ -52,7 +52,10 @@ drift = [o for o in ops if not ignored(o)]
for o in drift:
db = o.get("database") or ""
obj = (db + "." + o["object"]) if db else o["object"]
- print(" " + o["kind"] + " " + o["object_type"] + " " + obj)
+ flag = " [UNSAFE]" if o.get("unsafe") else ""
+ print(" " + o["kind"] + " " + o["object_type"] + " " + obj + flag)
+ for line in (o.get("sql") or "").strip().splitlines():
+ print(" " + line)
sys.exit(1 if drift else 0)
' "$@"
}
diff --git a/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke b/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke
index 801c44823b4b..f742eb35c361 100755
--- a/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke
+++ b/tools/infra-scripts/clickhouse-multinode/multinode-migration-smoke
@@ -53,7 +53,14 @@ report_result() {
dump_logs_on_failure() {
local exit_code=$?
- if [ "$exit_code" -ne 0 ] || [ "$SMOKE_PASSED" != "1" ]; then
+ # A gate-stage failure is a schema mismatch, not an infra problem — check-live
+ # already printed the drift diff, so skip the container-log dump and let that
+ # diff be the last thing before the result banner.
+ local gate_failure=""
+ case "$SMOKE_STAGE" in
+ dump_live_hcl | check_live_hcl) gate_failure=1 ;;
+ esac
+ if { [ "$exit_code" -ne 0 ] || [ "$SMOKE_PASSED" != "1" ]; } && [ -z "$gate_failure" ]; then
echo
echo "===================== FAILURE: dumping container logs ====================="
for svc in "${ALL_SERVICES[@]}"; do