en un clic
fix-sync
Fix the "CH Inc sync" job in a pull request. Diagnoses the failure as one of three types — conflicts found, build failed, or tests failed — and handles each accordingly.
Menu
Fix the "CH Inc sync" job in a pull request. Diagnoses the failure as one of three types — conflicts found, build failed, or tests failed — and handles each accordingly.
Extract the inner ELF from a ClickHouse self-extracting `clickhouse` binary, including when its architecture differs from the host (e.g. to load an aarch64 CI core dump on an x86 workstation). Use when gdb/lldb needs real symbols from a downloaded CI/release binary, or when self-extraction by running the binary is not possible because of an architecture mismatch.
Create a ClickHouse git worktree with submodules hardlinked from the main repo. Use when the user wants to create a new worktree for ClickHouse development.
Review a ClickHouse Pull Request for correctness, safety, performance, and compliance. Use when the user wants to review a PR or diff.
Continue work on an existing PR - resolve conflicts, fix CI failures, address reviewer feedback, and push updates. Use when the user wants to pick up and advance a pull request.
Generate PR descriptions for ClickHouse/ClickHouse that match maintainer expectations. Use when creating or updating PR descriptions.
Analyze ClickHouse Keeper stress-test results from play.clickhouse.com / keeper_stress_tests data warehouse. Use whenever the user asks about Keeper performance, validates Keeper PRs against stress dashboards, investigates regressions or improvements in Keeper nightlies, asks about specific date windows / SHAs / PR-sets in Keeper stress tests, wants per-PR or window-vs-window comparisons, asks "did this PR break Keeper", asks "what changed in Keeper between dates", or wants a summary report of Keeper stress runs. Triggers on terms like "keeper stress", "keeper PR", "keeper p99", "keeper memory", "keeper rps", "keeper nightly", "keeper-stress-tests", "keeper validation", "keeper regression", or any question referencing the keeper-stress Grafana dashboard. ALWAYS prefer this skill over re-deriving the workflow from scratch — it captures hard-learned lessons about cgroup-vs-Keeper memory, bench-harness confounds, noise floors, and per-PR attribution limits.
| name | fix-sync |
| description | Fix the "CH Inc sync" job in a pull request. Diagnoses the failure as one of three types — conflicts found, build failed, or tests failed — and handles each accordingly. |
| argument-hint | <pr-number-or-url> |
| disable-model-invocation | false |
| allowed-tools | Task, Bash(gh:*), Bash(cd:*), Bash(git:*), Bash(ls:*), Bash(pwd:*), Bash(mktemp:*), Read, Grep, Glob, AskUserQuestion |
Fix the "CH Inc sync" CI job for a ClickHouse pull request. The job runs the corresponding clickhouse-private sync PR through merge and private CI, so it can fail in three distinct ways. This skill first diagnoses which type of failure occurred, then applies the matching fix.
The "CH Inc sync" commit status on the public PR reports its failure as one of three descriptions (set by the private CI in clickhouse-private: ci/jobs/private_sync_pr.py for conflicts, ci/jobs/scripts/workflow_hooks/private_sync_complete_check.py for build/test failures):
conflicts found — the sync PR cannot be merged with master of clickhouse-private (mergeable == CONFLICTING). Resolve the merge conflicts and push.build failed — the sync PR merges cleanly, but a build job in the private CI fails. Usually the upstream change needs adaptation in private-only code that references changed symbols. Fix the build and push.tests failed — the sync PR merges and builds, but test jobs fail. The failure is either flaky/infra-related (rerun the failed jobs) or a genuine regression (investigate).The pending description testing means CI is still running — wait rather than act.
$0 (required): PR number or full GitHub URL of the public ClickHouse PR (e.g., 96005 or https://github.com/ClickHouse/ClickHouse/pull/96005)When a PR is opened in ClickHouse/ClickHouse, a sync PR is automatically created in ClickHouse/clickhouse-private on a branch named sync-upstream/pr/<PR_NUMBER>. The "CH Inc sync" check on the public PR reflects the state of that private sync PR: it stays pending/failing if the sync PR has conflicts, fails to build, or has failing tests.
$ARGUMENTShttps://github.com/ClickHouse/ClickHouse/pull/96005), extract the number from the URLAskUserQuestion to ask for the PR numbergh pr list --repo ClickHouse/clickhouse-private --head sync-upstream/pr/<PR_NUMBER> --json number,url,state,mergeable,mergeStateStatus,headRefName,headRefOid
This is the key step. Determine which of the three failure types applies before doing any work.
Read the "CH Inc sync" commit status description on the public PR — it directly states the failure type:
gh api repos/ClickHouse/ClickHouse/commits/<HEAD_SHA>/statuses --jq '.[] | select(.context == "CH Inc sync") | {state, description}'
(Get <HEAD_SHA> from gh pr view <PR_NUMBER> --repo ClickHouse/ClickHouse --json headRefOid.)
Map the description to a handler:
conflicts found → Conflicts found → step 4A.build failed → Build failed → step 4B.tests failed → Tests failed → step 4C.testing (state pending) → CI is still running. Report this and stop — wait rather than act.completed (state success) → no action needed, stop.If the status description is missing or ambiguous, fall back to inspecting the sync PR directly:
mergeable is CONFLICTING (or mergeStateStatus is DIRTY) → Conflicts found → step 4A.gh pr checks <SYNC_PR_NUMBER> --repo ClickHouse/clickhouse-private. A failing job whose name starts with Build → Build failed (step 4B); only test jobs failing → Tests failed (step 4C).Report the diagnosed failure type to the user before proceeding.
clickhouse-private repository in common locations relative to the current working directory:
../ClickHouse_private../clickhouse-privateClickHouse/clickhouse-private as a remoteAskUserQuestion to ask the user for the pathIn the private repository directory:
cd <private_repo_path> && git fetch origin && git fetch origin sync-upstream/pr/<PR_NUMBER>
Then check out the sync branch:
cd <private_repo_path> && git checkout sync-upstream/pr/<PR_NUMBER>
If the branch has local changes, ask the user before proceeding.
cd <private_repo_path> && git merge origin/master
This will likely produce conflicts. Handle them:
List conflicted files:
cd <private_repo_path> && git diff --name-only --diff-filter=U
For each conflicted file, use a Task agent with subagent_type=general-purpose to resolve:
<<<<<<<, =======, >>>>>>>)git add <file>IMPORTANT: If conflicts are complex or ambiguous, show the conflicts to the user and ask how to resolve them using AskUserQuestion.
After resolving all conflicts, complete the merge:
cd <private_repo_path> && git commit --no-edit
cd <private_repo_path> && git submodule update --init --recursive
If submodule update fails, report the error but continue.
Then go to step 5 (push and verify).
A clean merge that fails to build almost always means the upstream change renamed, moved, or changed the signature of something that private-only code depends on, or the merge needs a code adaptation that conflict resolution did not surface.
Fetch the build log to find the exact error. Identify the failed build run and download its log:
gh run list --repo ClickHouse/clickhouse-private --branch sync-upstream/pr/<PR_NUMBER> --json databaseId,name,conclusion,headSha
Use the public CI log tool when a report URL is available (see .claude/tools/fetch_ci_report.js), or inspect the failed job log via gh run view --log-failed.
Locate the build error (compile error, linker error, missing symbol). Use a Task agent with subagent_type=general-purpose to analyze the log and return only the relevant error excerpt and the file/symbol involved.
Reproduce and fix in the private repo. Check out the sync branch (fetch + merge origin/master if not already merged), then fix the offending private code to match the upstream change. Prefer adapting the private code to the new upstream API rather than reverting the upstream change.
Optionally rebuild to verify (see step 5's build verification).
Then go to step 5 (push and verify).
Merge and build are fine, but tests fail. First decide whether the failure is flaky/infra or genuine.
Fetch the failing test details:
gh pr checks <SYNC_PR_NUMBER> --repo ClickHouse/clickhouse-private
gh run list --repo ClickHouse/clickhouse-private --branch sync-upstream/pr/<PR_NUMBER> --json databaseId,name,conclusion
Classify as flaky/infra if the failures are infrastructure errors unrelated to the PR's changes, e.g. Cannot start clickhouse-server, Timeout, network/disk errors, or failing tests that touch areas the PR does not modify. (See the pr-89842-sync-rerun note: a PR touching only src/IO/* had Cannot start clickhouse-server / Timeout failures — clearly unrelated.)
gh run rerun <RUN_ID> --repo ClickHouse/clickhouse-private --failed
Otherwise, treat as a genuine regression. Use a Task agent to fetch and summarize the failing test logs, then report the failing tests and the likely cause to the user. Do not push speculative fixes without confirmation — use AskUserQuestion to decide next steps.
This path normally does not push to the sync branch (unless a genuine fix is made), so skip step 5 unless a code change was committed.
Use AskUserQuestion to ask the user:
cd <private_repo_path> && git push origin sync-upstream/pr/<PR_NUMBER>
After pushing (or rerunning):
gh pr view <SYNC_PR_NUMBER> --repo ClickHouse/clickhouse-private --json mergeable,mergeStateStatus
gh pr checks <SYNC_PR_NUMBER> --repo ClickHouse/clickhouse-private
Report the result per failure type:
mergeable is now MERGEABLE: "Sync PR is now mergeable. The CH Inc sync check should pass shortly." If still conflicting: "Sync PR still has conflicts. Additional investigation may be needed."Provide the sync PR URL for the user to check.
/fix-sync 96005 - Diagnose and fix sync for PR #96005/fix-sync https://github.com/ClickHouse/ClickHouse/pull/96005 - Fix sync using full URLMERGEABLE does nothing useful — for build/test failures the fix is different (see the pr-89842-sync-rerun note: rerun failed jobs rather than /fix-sync when no merge conflict exists).sync-upstream/pr/<PR_NUMBER>