Skylar AI On-premises Upgrade Guide

Download this manual as a PDF file

This chapter details the upgrade steps for Skylar AI.

The following upgrade path is supported for this release:

  • Skylar AI 2.8 > 2.9

Prerequisites:

  • Skylar Analytics only: Kubernetes version 1.32 or later

  • Skylar Advisor and Skylar Analytics: Kubernetes version 1.35 or later with a container runtime that supports OCI image volume, such as ContainerD 2.1 or cri-o 1.32 or later runtime

For more information, see Skylar AI Cluster Requirements.

Before Upgrading

Complete the following steps before beginning the upgrade to this release.

ClickHouse HA

If you are upgrading to Skylar AI 2.8.0 from 2.7.0 or earlier, you will need to migrate ClickHouse to High Availability. For more information, see ClickHouse HA Upgrade Procedure. If you are installing Skylar AI 2.9.0 from an ISO or upgrading from 2.8.x to 2.9.0, you do not need to run the ClickHouse HA upgrade.

ClickHouse is used within Skylar Analytics for high availability and improved site reliability. The default deployment requires three replicas across separate nodes or Availability Zones, but users can customize these requirements with new availability profile overrides, supporting "soft-ha" mode for preferred spreading or "no-ha" mode to disable high availability entirely.

Grafana SSO

You can set up Grafana SSO by implementing the grafana-sso.tffile in the examples directory.

examples/grafana-sso-no-argocd/grafana-sso.tf

New Metrics Exporter

The new metrics exporter for the ebs-csi driver exposes IOS/Throughput metrics. You can use the following query to see if volumes are exceeding the provisioned IOS/Throughput. This is included in the grafana skylar-monitoring dashboard, which is included in Terraform.

(sum by (volume_id) (rate(aws_ebs_csi_exceeded_tp_seconds_total[$__rate_interval])) *
 on(volume_id) group_left(claim_namespace, name) max by (volume_id, claim_namespace, 
name) (label_replace(kube_persistentvolume_info{csi_driver="ebs.csi.aws.com"} * 
on(persistentvolume) group_left(claim_namespace, name) 
kube_persistentvolume_claim_ref, "volume_id", "$1", "csi_volume_handle", "(.*)")))) > 0)

EKS Upgrade

You can upgrade eks.tf with the 1.37 GPU AMI.

You will need to consider what you will do after updating the AMI. Rolling the node might not be possible due to availability concerns.

Use the Ubuntu 24.04 LTS (Noble), amd64 from this page https://cloud-images.ubuntu.com/docs/aws/eks/. Be sure to update eks.tf with the right AMI for the region.

Helm Installation

Pull down the latest configuration files for sizing and High Availability (HA) profile:

oras pull registry.scilo.tools/skylar/skylar-helm-charts-sizing:v2.9.0
oras pull registry.scilo.tools/skylar/availability-helm-chart-overrides:v2.9.0

tar -xvf sizing.tar.gz
tar -xvf availability.tar.gz

#Copy sizing file to configs directory
cp analytics-small.yaml skylar-ai-conigs/


#Copy availbility file to configs directory 
cp soft-ha.yaml skylar-ai-configs/

Inside skylar-ai-configs/upgrade.txt you will find the helm install command you used during install time. Use that command, appending --version 5.7.0 to install Skylar AI 2.9.0.

ClickHouse HA Upgrade Procedure (Skylar AI 2.8.0)

If you are upgrading from an older version to Skylar AI 2.8.0, you will need to upgrade your system to enable High Availability (HA) for ClickHouse. If you are installing Skylar AI 2.9.0 from an ISO or upgrading from 2.8.x to 2.9.0, you do not need to run the ClickHouse HA upgrade.

ClickHouse holds the analytics and reporting data for Skylar AI. Before Skylar AI version 2.8, ClickHouse runs as a single replica: one pod holds the only copy of the data. If that pod fails, the analytics plane is unavailable until you restore it from backup.

High availability (HA) replaces the single replica with several replicas. Each replica holds a full copy of the data, and ClickHouse Keeper coordinates the replicas. If a pod or a node fails, performance degrades, but the analytics plane stays up, because the surviving replicas carry the full load until the failed replica returns. With HA, you can also pin the heaviest readers to different replicas instead of sending them all to one server.

To enable HA, you make a one-time change to how ClickHouse declares its databases and tables. Replication is a property of the engine, so you cannot switch it on in place. This procedure makes that change.

In version 2.8, Skylar AI converts each tenant ClickHouse databases from ENGINE = Atomic to ENGINE = Replicated. It converts their tables from the MergeTree family to the Replicated*MergeTree family.

This procedure is required for every installation, including installations that run only one ClickHouse replica. It is the prerequisite for adopting HA later. Running more than one replica is optional. Steps and paragraphs marked HA only apply only where replicaCount is greater than 1.

Run the migration immediately before helm upgrade, from a pod in the cluster, with ClickHouse running and all writers stopped. The migration renames each database aside, recreates it with the Replicated engine, and moves the data back with ATTACH PARTITION. This command uses hardlinks, so the migration does not rewrite any data.

The outage lasts from the quiesce step to the end of the upgrade. Plan for about 60 minutes, assuming a warm snapshot chain and the default parallelism. The work before and after that span causes no downtime. For more information, see Estimated Runtime.

Set Environment Variables

Set the following variables one time, in the shell where you run the commands in this procedure. Every command that follows then works as written, without further replacements.

To set the environment variables, run the following commands:

export NS=<namespace>
# helm chart release name
export REL=$(helm ls -n "$NS" | awk '/skylar-charts-/ {print $1}')
export IMAGE=registry.scilo.tools/skylar/skylar-upgrade-toolbox:v1.14.0

# leave unset if the cluster has no VolumeSnapshotClass -- see below
export CLASS=<volumesnapshotclass>

Replace <namespace> with the namespace of your deployment, and replace <volumesnapshotclass> with the VolumeSnapshotClass that you want to use.

CLASS is the VolumeSnapshotClass that the procedure uses to take snapshots. To list the classes, run kubectl get volumesnapshotclass. If the cluster has one class, use it. If the cluster has several classes, choose deliberately: a wrong class produces a snapshot set that you cannot restore from. If the cluster has no snapshot class, you cannot create snapshot backups. In that case, leave CLASS unset, and add --skip-snapshot when you run the migration later.

Shell variables do not persist between sessions, and this procedure spans several days. Run the commands again whenever you return to the procedure. The scripts inside the pod read the release name and the snapshot class from their own environment, so no script invocation repeats them.

Setup: Get a Shell in the Cluster

The setup pod creates snapshots and runs preflight checks in advance. The checks raise issues that might be problematic for the upgrade. Even if you do not plan to create snapshots, create the pod and run the preflight checks in Step 2 before the upgrade day. The preflight checks also run as part of the migration on the upgrade day, before the migration modifies anything.

The scripts run in the cluster, from a pod that starts from the 2.8 toolbox image. You do not need to wait for the chart to deploy the pod.

To create the setup pod and open a shell in it:

  1. Create the pod:

    kubectl -n "$NS" apply -f - <<EOF
    apiVersion: v1
    kind: Pod
    metadata:
      name: skylar-ch-ha
    spec:
      restartPolicy: Never
      serviceAccountName: skylar-sa
      containers:
        - name: toolbox
          image: ${IMAGE}
          command: ["tail", "-f", "/dev/null"]
          env:
            - name: HELM_RELEASE_NAME
              value: "${REL}"
            - name: SNAPSHOT_CLASS
              value: "${CLASS}"
          resources:                                  # equal requests/limits = Guaranteed QoS
            requests: { cpu: "1", memory: 2Gi }
            limits:   { cpu: "1", memory: 2Gi }
    EOF
  2. Wait for the pod to become ready:

    kubectl -n "$NS" wait --for=condition=Ready pod/skylar-ch-ha --timeout=180s

  3. Open a shell in the pod:

    kubectl -n "$NS" exec -it pod/skylar-ch-ha -- /bin/bash

The resources block is required. An under-resourced pod can be killed for running out of memory when 30_migrate.sh starts its default of 16 workers. If you cannot give the migration pod these resources, lower the WORKERS environment variable in the manifest.

No script in this procedure needs the --ns or --rl option. The release name comes from HELM_RELEASE_NAME in the pod, and the namespace comes from the pod itself. Both options still work if you need to override either value.

From this point, run the scripts under /home/runner/ in the pod shell. Run kubectl and helm from your own machine. Every invocation appears in full, so none depends on the working directory. Step 3 is the exception: it launches its own detached pod, so the migration survives a dropped connection.

Pre-Upgrade Preparation (Days Before)

Complete the steps in this section in the days before the upgrade window.

Step 1: Warm the Snapshot Chain

If your cluster uses Amazon Elastic Block Store (EBS) for storage, warm the snapshot chain when the ClickHouse, Keeper, and Postgres volumes have no recent snapshot. Otherwise, the snapshot in Step 3 blocks on a full copy. If Velero takes periodic snapshots, you already have a recent snapshot, but confirm that instead of assuming it. If your cluster uses any other storage, skip this step.

For more information, including the storage caveat, see Step 1: The Snapshot Chain.

To warm the snapshot chain:

  1. Submit the warm-up snapshots:

    /home/runner/manual-scripts/2.8/clickhouse-ha-migration/prep/warmup_snapshots.sh --no-wait

    The --no-wait option submits the snapshots and returns instead of polling, which can take hours.

  2. Check the status:

    /home/runner/manual-scripts/2.8/clickhouse-ha-migration/prep/warmup_snapshots.sh --status

    Before the upgrade window, confirm that every row reads READY=true.

Step 2a: Run Preflight

Preflight is read-only. Clear anything that it reports before the upgrade window.

To run preflight, run the following command:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/pre-upgrade/run_migration.sh --only preflight

If the cluster does not take snapshots, add --skip-snapshot to this command as well. That option turns off the snapshot validation checks, which otherwise report a finding on every run. Adding the option records your decision.

An orphans finding that names bkp_* tables is expected in some longer-running environments. These tables are leftover backups from the 1.8 and 2.1 upgrades that were never cleaned up. Leaving them causes no data loss, but the migration converts and replicates them. ScienceLogic recommends that you delete them. For more information, see Step 2: Migration Debris Holding Data.

Step 2b: Spread Keeper Volumes (Situational)

Skip this step unless Step 2 reported a keeper-topology finding.

Also skip this step if you use availability/soft-ha.yaml on the Helm upgrades, because that file removes the requirement for Keeper volumes to be on separate zones or nodes. If you skip the step for this reason, you must bypass preflight by uncommenting --from=quiesce in the migration manifest in Step 3.

If Keeper volumes share an availability zone, or share a node on clusters that have no zones (on-premises clusters), spread them out. If you leave them in place, the upgrade in Step 6 leaves a Keeper pod in the Pending state permanently and stalls its rolling update. Clearing this condition needs no outage, so do it days early.

To spread the Keeper volumes, run the following command:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/prep/spread_keeper_volumes.sh

Run the script with --status or --dry-run first. Neither option changes anything. The --status option reports the placement and the plan. The --dry-run option also prints every command that the script would run, including the affinity patch. If a collision exists, the real run discards one Keeper volume and restarts every Keeper pod, one at a time, to apply the placement rule. If the volumes are already spread out, the script reports that and exits, so a run made in error does nothing.

After the script finishes, run Step 2 again to confirm that the finding cleared. For more information, including the mechanism and what to do on a cluster that has fewer zones than Keeper replicas, see Step 2b: Keeper Volume Placement.

You need the setup pod only for the script steps: Steps 1 to 2b, and again at sign-off (Steps 10 and 11). You also need it for a rollback. Delete the pod in between instead of leaving it idle for days, and recreate it when you need it. For more information, see Setup: Get a Shell in the Cluster.

To delete the setup pod, run the following command:

kubectl -n "$NS" delete pod skylar-ch-ha

Upgrade (Outage Incurred)

The outage begins when you run Step 3 and ends when the workloads are up after Step 6.

Step 3: Run the Migration

Run the migration with one command, unattended. The migration runs preflight, and then it quiesces every Deployment in the namespace. Next, it takes snapshots of the ClickHouse, Keeper, and Postgres PersistentVolumes (PVs) while all three are stopped. Then it brings ClickHouse back up to migrate the database tables, verify that the migration succeeded, and update the dataviz ClickHouse instances to support the migrated tables.

To run the migration, run the following command:

kubectl -n "$NS" apply -f - <<EOF
apiVersion: v1
kind: Pod
metadata:
  name: skylar-ch-ha-migration
spec:
  restartPolicy: Never
  serviceAccountName: skylar-sa
  containers:
    - name: migration
      image: ${IMAGE}
      command:
        - /home/runner/manual-scripts/2.8/clickhouse-ha-migration/pre-upgrade/run_migration.sh
        - --yes
        - --hold                                  # stay alive so the log can be copied out
        # - --skip-snapshot                       # no VolumeSnapshot support in this cluster
        # - --from=quiesce                        # skip preflight (see below)
      env:
        - name: HELM_RELEASE_NAME
          value: "${REL}"
        - name: SNAPSHOT_CLASS
          value: "${CLASS}"
        - name: LOG_FILE
          value: /tmp/ch-ha-migration.log
        - name: WORKERS                             # lower if the resources below are not available
          value: "16"
      resources:                                  # equal requests/limits = Guaranteed QoS
        requests: { cpu: "1", memory: 2Gi }
        limits:   { cpu: "1", memory: 2Gi }
EOF

The following table lists the options that you can enable by uncommenting lines in the command.

Option When to Use It

--skip-snapshot

The cluster has no VolumeSnapshot support. This option gives up the coarse rollback. The _backup databases are then the only fallback, and only until Step 10b.

--from=quiesce

Skips preflight, when you already read its report in Step 2 and judged the findings to be non-blocking. Preflight stops the run before it changes anything, so this option is how you proceed past it. For more information, see Step 2: Preflight Exit Codes.

Step 4: Follow the Pod Logs

To follow the pod logs, run the following command:

kubectl -n "$NS" logs -f pod/skylar-ch-ha-migration

If you lose the connection, the run continues, because the pod is detached. Step 5 copies the complete log out of the pod, so you do not need to capture anything here.

A successful run ends with the following output:

==============================================================================
  ALL STEPS COMPLETED in <N>s
==============================================================================

==============================================================================
  MIGRATION FINISHED -- exit code 0
==============================================================================

A run that stops early ends with STOPPED at <step> and a non-zero exit code.

Step 5: Retrieve the Log and the Exit Code

The pod stays in the Running phase after the migration finishes. This behavior is deliberate, so that you can copy out the complete log. For more information, see Step 3: Why the Command Looks the Way It Does. The pod phase therefore tells you nothing about the outcome. The appearance of /tmp/exit-code marks the run as finished. If the file does not exist (No such file), the run is still going.

To retrieve the exit code and the log:

  1. Read the exit code:

    kubectl -n "$NS" exec skylar-ch-ha-migration -- cat /tmp/exit-code

  2. Copy the log to your machine:

    kubectl -n "$NS" exec skylar-ch-ha-migration -- cat /tmp/ch-ha-migration.log > ./ch-ha-migration.log

An exit code of 0 means that the migration is done. An exit code of 4 means that findings need a decision, and no step after that one ran. If a finding occurs, see Step 3: If a Step Stops for how to resume the migration after you address the finding.

Delete the pod after you have both the exit code and the log. The pod holds a Guaranteed reservation of 1 CPU and 2 Gi of memory until you remove it.

To delete the migration pod, run the following command:

kubectl -n "$NS" delete pod skylar-ch-ha-migration

Step 6: Run Your Normal Helm Upgrade

Run your normal Helm upgrade. This step is required for every installation. The outage ends when the workloads are up.

HA only. Include the clickhouse-ha-migration.yaml override file at the end of your upgrade command, as -f upgrades/clickhouse-ha-migration.yaml. Place it after your own values files so that it takes precedence. Leaving out this file can cause permanent data loss. For more information, see Steps 6 and 8: Why Two Helm Upgrades. You remove the file in Step 8.

HA only. EBS only. Raise the input/output operations per second (IOPS) and the throughput on the new replica volumes now, in the AWS console. This step creates the volumes at the StorageClass baseline, and they are the bottleneck for the clone in Step 7. The difference is about 30 minutes compared with about 2.4 hours for the gate. For more information, see Step 7: The Gate.

Post-Helm Upgrade

Step 7: Wait for the 2.8 Upgrade Gate

HA only. This step is automatic. The skylar-upgrade-toolbox pod runs it on the post-upgrade hook. The pod joins any replica that is still missing its databases, and it holds the upgrade open until every replica catches up. You do not need to run anything.

Step 8: Run Your Normal Helm Upgrade Again, Without the Override File

HA only. Run your normal Helm upgrade again, without -f upgrades/clickhouse-ha-migration.yaml. This step is required, not optional. Removing the override file redistributes the replica pins.

Step 9: Soak

Keep the soak short: hours, not weeks. Watch the free disk space, because the _backup databases keep the pre-migration parts alive. For more information, see Step 9: The Soak.

Upgrade Sign-Off

Step 10a: Review What the Script Would Drop

This step is read-only and changes nothing. It reports sizes, the estimated Keeper cost, and any table that reaches max_table_size_to_drop.

To review what the script would drop, run the following command:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/post-upgrade/drop_backups.sh --status

Step 10b: Drop the Backups

This step is irreversible. It is the point of no return. Afterward, the VolumeSnapshot is the only way back, and only until it expires. Do not run this step until you sign off on the soak.

To drop the backups, run the following command:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/post-upgrade/drop_backups.sh

Step 11: Clean Up

To clean up:

  1. In the pod, delete the warm-up snapshots, and then exit the shell:

    /home/runner/manual-scripts/2.8/clickhouse-ha-migration/prep/warmup_snapshots.sh --delete

    exit

  2. From your own machine, delete the pods:

    kubectl -n "$NS" delete pod skylar-ch-ha skylar-ch-ha-migration --ignore-not-found

This command deletes the interactive pod. Step 5 already deleted the migration pod. The --ignore-not-found option covers the case where you skipped that deletion.

Rollback on Critical Failure

A rollback runs interactively from a pod, not as a one-shot run like Step 3. Both rollback scripts ask you to type the namespace before they do anything destructive.

R1: Run the Helm Rollback First

The Helm rollback is not one of the scripts, and the order is not optional. For more information, see Rollback Details.

To roll back Helm:

  1. Run the following command. Replace <pre-upgrade-revision> with the Helm revision from before the upgrade.

    helm rollback "$REL" <pre-upgrade-revision> -n "$NS"

  2. Confirm that the replica count is the count that you want to restore:

    kubectl -n "$NS" get sts

R2: Get a Shell

Reuse the pod from Setup: Get a Shell in the Cluster, or create it the same way if you already deleted it.

To open a shell in the pod, run the following command:

kubectl -n "$NS" exec -it pod/skylar-ch-ha -- /bin/bash

R3: Find the Snapshot Set Tag

To find the snapshot set tag, run the following command in the pod shell:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/rollback/10_rollback_from_snapshot.sh --list

R4: Restore ClickHouse, Keeper, and Postgres

This script deletes the live PersistentVolumeClaims (PVCs). Read the preflight summary that the script prints, and then type the namespace to confirm.

To restore ClickHouse, Keeper, and Postgres, run the following command in the pod shell:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/rollback/10_rollback_from_snapshot.sh --tag <snapshot-tag>

Replace <snapshot-tag> with the tag from R3.

R5: Reset DataViz

This script drops and rebuilds the DataViz _reporting tables against the rolled-back core. It also clears the Keeper registrations that the restore brought back.

To reset DataViz, run the following command in the pod shell:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/rollback/20_rollback_dataviz.sh

If the script completes, R5 is done. Skip the rest of this step.

If the script aborts with could not POST through the API server service proxy, the cluster runs a service mesh, and the API server cannot reach reporting-manager through it. In that case, trigger the redeploy manually from your workstation.

To trigger the dataviz redeploy manually:

  1. Port-forward to reporting-manager, and trigger the redeploy. Replace <core-namespace> with the namespace of the core deployment.

    kubectl -n <core-namespace> port-forward svc/reporting-manager 8000:8000 &
    curl -sS -XPOST localhost:8000/api/v1/reporting/upgrade
  2. Wait for every dataviz release to report deployed before you continue:

    curl -sS localhost:8000/api/v1/reporting/health

    The table drops assume that the dataviz releases are already back on the rolled-back chart, and the loop in reporting-manager cannot detect a chart downgrade.

  3. Run the script again, and skip the trigger that it already received:

    /home/runner/manual-scripts/2.8/clickhouse-ha-migration/rollback/20_rollback_dataviz.sh --skip-reporting-upgrade

On a cluster with a service mesh, the dataviz release status per deployment line of the script is absent instead of wrong, because the script reads through the same proxy. Confirm deployed through the port-forward, not by the absence of a warning.

If you need to run these scripts unattended, --force (R4) and --yes (R5) skip the confirmations. In that case, invoke the scripts the same way as in Step 3: by full script path, with no cd, because no TTY exists to answer a prompt.

For more information about what a rollback does not cover, see Rollback Details.

Estimated Runtime

The following table lists the planning figures for the upgrade.

Phase Plan For

Outage: Steps 3 to 6, with services down

Book about 60 minutes

Start of the window to pins redistributed: Steps 3 to 8

About 1.5 to 2 hours, or about 3.5 to 4 hours if you leave the replica volumes at the StorageClass baseline

These figures are planning figures with buffer, not the measured sum. Both include two Helm upgrades, whose duration depends on your environment. Steps 1 to 2b, 9, and 10 are outside these figures.

The second row is not an outage, but it is degraded. Until Step 8 redistributes the pins, a read can land on a replica that is still filling, and the read can return partial or empty results instead of an error. For more information, see Step 7: The Gate.

Breakdown by Step

Italicized values are modelled. They come from per-statement costs in a surveyed estate of 12 tenants and about 1 TiB, multiplied out. They are not observations. Unmarked values are rough envelopes. For more information about the inputs, see Cost Model.

Step Services Down? Duration

Step 1: Warm the snapshot chain

No

Minutes to submit; hours in the background

Step 2: Preflight

No

2 to 5 minutes

Step 2b: Spread Keeper volumes (situational)

No

About 5 minutes per volume moved

Step 3: Migration (phases below)

Yes

About 40 minutes modelled; book 60

Quiesce

Yes

1 to 3 minutes

Snapshot

Yes

2 to 5 minutes warm; hours cold

Migrate

Yes

24 minutes at--workers 16; about 6.5 hours serial

Verify

Yes

1 to 3 minutes

Dataviz re-couple

Yes

About 2 to 6 minutes, in parallel across instances

Step 6: Helm upgrade (with the override file)

Recovering

Depends on your environment

Step 7: Upgrade gate

No

HA only.About 30 minutes tuned; about 2.4 hours at the StorageClass default

Step 8: Helm upgrade (without the override file)

No

Depends on your environment

Step 10: Drop the backups

No

About 5 minutes parallel; about 35 minutes serial

Detailed Background Information for Each Step

The sections that follow explain the reasoning behind each step. Read them to understand why the procedure works the way it does and how to respond when a step reports a finding.

Prerequisites and the Pod

The commands are in Setup: Get a Shell in the Cluster. This section explains the reasoning behind them.

The serviceAccountName setting is required. The skylar-sa service account already exists from the current release. It carries the registry pull secret and role-based access control (RBAC) permissions that are wide enough to scale StatefulSets, read secrets, create VolumeSnapshots, and exec into pods. With the default service account, the pod cannot pull the image, and every kubectl call inside the pod fails.

Run every step from the pod. Inside the cluster, the pod reaches ClickHouse over per-pod DNS at about 30 milliseconds per statement. From outside the cluster, access falls back to kubectl exec at about 0.3 to 2 seconds per statement. That slowdown turns the migrate step from minutes into hours, and it can push waiting steps past their own timeouts.

Also confirm the following items before the upgrade day:

  • The command kubectl -n "$NS" get sa skylar-sa -o jsonpath='{.imagePullSecrets[*].name}' returns a secret.

  • VolumeSnapshot support exists. If it does not (typically on-premises), run the migration with --skip-snapshot, and accept the _backup databases as the only rollback.

  • You know which VolumeSnapshotClass to use. To list the classes, run kubectl get volumesnapshotclass. Both pods take the class as SNAPSHOT_CLASS.

  • Disk headroom exists. Preflight warns if less than 20% of the disk is free.

  • HA only. You decided on the IOPS and throughput for the new replica volumes. That choice makes the difference between a gate of about 30 minutes and a gate of about 2.4 hours. Decide before the upgrade day, but perform the action right after Step 6, because the volumes do not exist until the StatefulSet scales out. For more information, see Step 7: The Gate.

Step 1: The Snapshot Chain

The real snapshot happens inside the window, with ClickHouse, Keeper, and Postgres all stopped. On a cold volume, that snapshot blocks on a full copy. A throwaway snapshot that you take days earlier, with nothing scaled and no downtime, makes the real snapshot a delta.

The --no-wait option skips the polling and keeps your terminal free. The storage backend still copies the data in the background, so confirm the result later with --status.

If Velero already snapshots these volumes on a schedule, the chain is warm, and you can skip Step 1. The chain is per volume, and it does not depend on which tool created the parent snapshot, so any scheduled backup tool counts. Retention that deletes older snapshots does not make the chain cold. The script reports the most recent backing snapshot for each volume, so check instead of assuming.

Storage note. This step assumes that snapshots are copied out of the storage of the volume. That behavior is a property of EBS, not of Kubernetes. Most on-premises drivers (LVM, ZFS, Ceph RBD, NetApp, vSphere, and Longhorn) snapshot copy-on-write within the same pool. Creation is instant, so no full copy exists to pay for in advance, and warming buys nothing. The snapshot consumes pool space in proportion to how far the live volume diverges from it. Warming days early therefore costs space for days with no benefit. On LVM, a snapshot whose allocated space fills is invalidated outright.

The provisioner name alone cannot tell you which type of storage you have. If you do not know, assume copy-on-write, and skip the warm-up. To settle the question for each environment, snapshot a small test PVC, write a few GiB to its origin, and watch whether the free space in the pool drops.

These snapshots are not a rollback target. You take them while the volumes are live, so they are crash-consistent at best. Keeper uses a Raft log, so restoring a warm-up snapshot could hand back a state that no replica ever agreed on. The rollback script refuses these snapshots unless you explicitly override it.

Delete the warm-up snapshots after sign-off in Step 11, not before. Deleting a warm-up snapshot first frees the blocks that only it holds, and the real snapshot would have to copy them again.

Step 2: What Preflight Checks

Preflight is read-only, and it is designed to stop on decisions instead of failures.

Nothing in the following table changes anything. The Outcome column describes what preflight does with each result.

Check Outcome

In-scope databases, listed in full

The worklist. Preflight classifies each database as fresh, resume, done, or stalled. The presence of <db>_backup separates a mid-migration database from an already-done database, because both report Replicated.

Empty in-scope databases

Preflight names them on one line. An empty _otel or tenant base means that the migration does not exercise that path at all.

Work size: attach statements, parts, rows, and bytes

The wall-clock estimate. Attach statements dominate the estimate, not bytes.

Table engines present

An engine that the transformation does not recognize is a finding here, instead of a surprise at table 400.

Tables the migration skips

Preflight resolves them against this cluster instead of printing a regular expression. Expect 10 per tenant in *_rptsource, plus <tenant>_otel.snap_samples where streaming telemetry is enabled.

Disk headroom

Warns when less than 20% of the disk is free.

Snapshot support: custom resource definitions (CRDs) and VolumeSnapshotClass

Finding, unless the run passes --skip-snapshot. Preflight reports absent CRDs and a missing class separately. Either one means that the snapshot step cannot run, and the run would abort after quiesce, so make the decision before the window instead of during the outage.

Zero-copy replication, server-wide and per table

Finding.ATTACH would copy instead of hardlink, so budget disk and time for a full copy.

bkp_* and *_upgrade_bak debris that holds rows

Finding. No live service recreates these tables, and the migration would replicate them to every new replica.

*_orig databases

Warning only. This migration never creates them, so they are leftover scratch.

Active queries

Must be 0 by the time migrate runs. The quiesce step brings the count to 0.

default_replica_path

Informational. A name-based path is the expected pre-2.8 value. The snapshot step rewrites it to {uuid} and applies it with the ClickHouse restart that the step already performs.

Keeper replica count

Fails at 0, because Replicated engines cannot work without Keeper.

Keeper health, per pod via mntr

Finding if the leader has fewer synced followers than the ensemble size implies.

Keeper znode count

A baseline worth keeping. You cannot recover it afterward, and the migration converts about 2,950 tables per installation to Replicated.

Keeper volume topology spread

Finding. Two Keeper volumes in one availability zone cannot satisfy the required anti-affinity of 2.8, and a bound volume cannot move between zones. The upgrade would therefore leave a Keeper pod in the Pending state permanently. Clear this finding before the window. For more information, see Step 2b: Keeper Volume Placement.

Step 2: Preflight Exit Codes

Exit Meaning

0

Ready

1

A precondition failed

4

Ready, but findings need a decision

The line step preflight: OK in the closing summary means exit 0. Nothing was found, and you have nothing to evaluate. Preflight reports anything that needs attention as completed with findings that need a decision (rc=4) instead, and the run stops there.

Exit 4 means that preflight is working correctly. Two findings need a real decision: leftover _backup databases (described next) and migration debris (described in Step 2: Migration Debris Holding Data). You act on the other findings directly, as the table in Step 2: What Preflight Checks describes.

Preflight cannot tell whether to resume an interrupted migration or start fresh, so it asks. Preflight is read-only and cannot take an answer, so it reports this finding on every run until the backups are gone. Skipping the finding is how you answer. To resume, go to --from migrate: an existing table skips its create, and an existing partition skips its attach. To start fresh, undo the partial migration first. No script does this. Run the following two statements for each database that the finding names, from the pod:

DROP DATABASE `<db>` SYNC;
RENAME DATABASE `<db>_backup` TO `<db>`;

The order matters, because the drop frees the name that the rename needs. The process is lossless only while services are still quiesced, which is the case here: nothing has written since the rename. The _backup tables kept Keeper paths that name the original database, so renaming them back makes the paths match again. Watch for max_table_size_to_drop (46.6 GiB) on the drop. If a partial table exceeds that size, drop the table by partition first.

Step 2: Migration Debris Holding Data

Preflight reports orphans: <N> debris table(s) with data for tables that match bkp_*, *_upgrade_bak, *_tmp_new*, or *_new. No live service recreates these tables, so preflight names them instead of ignoring them.

Expect this finding in most longer-running, pre-existing environments. It is not evidence that a past upgrade failed. Three earlier migrations left backups behind even on a completely successful run, because their cleanup was never automated. Those migrations are long retired, so this finding is residue that you clear a single time, not something that still accumulates. The following table lists the origin of each set of tables.

Left By Tables Typical Size

1.8 schema_change_obs.sh

bkp_aiml_metrics_obs_obs_reorder, per tenant

Large: tens of GiB

1.8 schema_change_fs.sh

bkp_fsstattab_170, per tenant

Large

2.1 evtstat_rebuild.sh

bkp_evt_activations_hourly, bkp_evt_clears_hourly, bkp_evt_duplicates_hourly

Small: hundreds of KiB

The two 1.8 scripts print a DROP command to their console output for an operator to run after verifying row counts, instead of issuing it themselves. The evtstat_rebuild.sh script has no DROP at all. In each case, the script restored the data into the live tables as the final step of that migration, so the backups are a pre-restore safety copy that nothing has read since.

Migrations from 2.3 (*_2_3_0_upgrade_bak) and 2.7.0 (*_new) drop their backups automatically, so those tables do not normally appear. If one does appear, that migration stopped on a row-count mismatch and deliberately kept the original. Investigate instead of dropping it.

If you compare row counts before you delete the backups, remember that the backups are frozen and do not age, while the live tables carry time-to-live (TTL) settings. A backup that shows more rows than its live counterpart is expected. The extra rows are data that has since passed retention.

Skipping this finding does not leave the tables alone. The migration recreates every MergeTree-family table that it finds in each renamed-aside database, and the only exclusions are the deliberately plain scratch tables listed in Step 2: What Preflight Checks. The migration therefore recreates debris as Replicated*MergeTree and attaches every partition, exactly as it does for a real table.

This choice is a cost decision, not a data-safety decision, because the rows survive either way. The following table lists the options.

Option Effect

Drop before migrating

The shortest window and the lowest cost afterward. The rows are gone.

Proceed past the finding

The rows are preserved. Each table becomes replicated, so its data is stored on every replica instead of one. The tables also add Keeper znodes and background merge work, and their partitions count toward the attach wall-clock time.

Rename out of scope first

The rows are preserved and left unreplicated. Use RENAME TABLE to move the table into a database outside the allowlist (not a tenant base, and not one of its five recognized extensions), and the migration ignores the table entirely. Verify it on a development cluster before you rely on it.

Dropping is the cheapest option, and it is safe where the tables are genuinely abandoned residue. It is still a deletion, so on customer-facing environments the decision belongs to whoever owns the data, not to the operator who runs the procedure. Proceeding past the finding is the conservative default, and it does not prevent you from dropping the tables later.

Step 2b: Keeper Volume Placement

Version 2.8 requires each Keeper replica to be in its own availability zone. Earlier releases only preferred separate nodes, which says nothing about zones. A pre-2.8 ensemble can therefore have two Keeper volumes in one zone, and many do. A volume cannot move between zones. When the upgrade applies the stricter rule, the Keeper pod whose zone already holds a peer never schedules again, and the Keeper rolling update stalls at that ordinal.

The ensemble keeps quorum at 2 of 3, so this condition is survivable instead of fatal. However, it leaves the ensemble with no fault tolerance during the scale-out and the initial replica clone, which are the heaviest Keeper load in the procedure. Clearing the condition days early avoids that risk.

The update discards the volume of the colliding replica so that the volume re-provisions in a free zone. This action is cheap for Keeper. The replacement rejoins under the same identity, and the leader streams it the current state (a few MB) in seconds. It does not need the care that a ClickHouse volume needs. The script holds quorum throughout and works on one replica at a time, so no outage occurs. Run the following command to apply the fix:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/prep/spread_keeper_volumes.sh

The script reports the plan and asks for confirmation before it changes anything. The --status and --dry-run options show the plan without a confirmation. The script refuses to guess when quorum is already short. It picks the topology key from the rule in force, and it falls back to zones, and then to nodes on a cluster that has no zone labels. Run preflight again afterward to confirm that the finding cleared.

On a cluster with no zone labels at all, the script spreads by node instead. It detects the condition and re-keys itself. One change does not follow automatically: the chart ships the rule keyed on zones, so you must re-key the Keeper podAntiAffinity rule to kubernetes.io/hostname in your own overrides file to match. Without that change, the upgrade reapplies a zone-keyed rule that matches no node at all. A node that is missing the key is ineligible for a required term that uses it, so every Keeper pod beyond the first stays in the Pending state no matter where the volumes are.

If the cluster has fewer zones (or nodes) than Keeper replicas, no volume move can help. The rule is unsatisfiable by arithmetic, and the script says so and stops. Keep the earlier behavior instead by setting the Keeper podAntiAffinity rule back to preferred in your own overrides file. Override only that block. Do not override availability/soft-ha.yaml, which also loosens ClickHouse, Postgres, and pgpool.

Step 3: What the Migration Runs, in Order

The step name in the left column is the value that --from and --only take. It is not the script name.

Step Name Script What It Does

preflight

00_preflight.sh

Runs read-only inventory and precondition checks.

quiesce

10_quiesce.sh

Scales every Deployment in the namespace to 0, plus the OpenTelemetry (OTel) collector custom resources. This step scales Deployments only, so ClickHouse, Keeper, and Postgres are untouched here. However, pgpool is a Deployment, and stopping it guarantees that nothing is connected when snapshot stops Postgres.

snapshot

20_snapshot.sh

Takes VolumeSnapshots of every ClickHouse, Keeper, and Postgres PVC, after it stops all three. It also sets the {uuid}default_replica_path, which needs a ClickHouse restart. This step therefore still runs under --skip-snapshot, but it takes no snapshots.

migrate

30_migrate.sh

Renames each database aside, runs CREATE DATABASE ... Replicated, recreates the objects, and runs ATTACH PARTITION.

verify

40_verify.sh

Runs an independent, read-only verification.

dataviz

50_recouple_dataviz.sh

Drops stale dataviz _reporting tables so that schema_sync rebuilds them.

The migration stops there. The Helm upgrade needs environment-specific values, so the migration does not automate it.

The migration never scales services back up, not even on failure. After 30_migrate starts, a database might be half-migrated, and bringing a writer up against that database puts writes into a database that is about to be replaced. The tenant-service would specifically re-create the database as Atomic. Restoring services is therefore always an explicit decision. The script only prints the command.

Step 3: Dry Runs

The --dry-run option propagates to every step that mutates anything: quiesce, snapshot, migrate, verify, and dataviz. Preflight is already read-only and takes no such option.

Use --dry-run for one step at a time, not for the whole plan. A full-plan dry run is close to meaningless, because each step inspects the current cluster, and the previous steps did not change it. The dry run of migrate shows renames against databases that are still Atomic, and then verify looks at a cluster where nothing was migrated and reports exactly that. The orchestrator gates on exit codes, so the chain usually stops early anyway.

A dry run is most useful for a single step that you want to inspect before you commit to it. Run the following commands from the pod:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/pre-upgrade/run_migration.sh --only migrate --dry-run --yes

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/pre-upgrade/run_migration.sh --only dataviz --dry-run --yes

Keep the following two caveats in mind:

  • 30_migrate.sh forces --workers 1 during a dry run, so the statement stream stays readable. The output is the plan, not a timing estimate.

  • 10_quiesce.sh --dry-run exits before the wait-for-pods-to-terminate and active-query checks, so a dry run does not exercise them. On the real run, active queries must reach 0 before migrate starts.

Step 3: Why the Command Looks the Way It Does

The command in Step 3 looks the way it does for the following reasons:

  • The --yes option is mandatory. With no TTY, stdin is closed, so the confirmation prompt reads end-of-file, gets an empty answer, and aborts before it does anything. This behavior can look like a permissions problem.

  • The pod runs detached, and you follow it with logs -f, not -it. The migration runs for tens of minutes, and attaching means that a dropped connection costs you the output stream. The logs -f command reconnects.

  • The --hold option keeps the pod alive after the run ends. Statement-level detail goes to LOG_FILE only, and kubectl logs carries the narrative, not that detail. Reading a file out of a pod needs kubectl exec, which a pod whose command has exited does not accept. For the same reason, the exit code goes to /tmp/exit-code: the pod phase no longer reports it.

  • A bare pod with restart=Never is not rescheduled. If the node drains or a spot instance goes away during migrate, the run dies where it stood. You can recover with --from, but an unclean kill can also leave a readonly table behind.

Step 3: Why the Control Plane Must Be Down Too

The migration stops everything, instead of a list of known writers. The window is already a platform-wide outage, and the Helm upgrade restores the replica counts afterward, so stopping extra services costs nothing. Stopping too few services costs a database that stays Atomic, or a table on a name-based Keeper path, with no error anywhere. An allowlist would have to be right about every service in the product, forever.

The tenant-service is the clearest example. Its reconcile issues CREATE DATABASE IF NOT EXISTS about every 600 seconds, which creates Atomic databases on a pre-2.8 image. If the reconcile fires between the rename and the recreate, the ENGINE = Replicated statement of the migration silently does nothing, because the name matches. That reintroduces the exact issue that the migration removes, with no error anywhere.

The migration also takes down the OTel collector, so the collector accepts no telemetry while the window is open. The gap equals the length of the outage. Data that is already in the persistent queue survives the restart and flushes afterward, but the collector captures nothing new in the meantime.

Step 3: If a Step Stops

The following table lists the exit codes of the migration.

Exit Meaning Next

0

All steps completed

Continue to the Helm upgrade

1

A step aborted

Read the failure, fix it, and resume

2

Usage or environment error; nothing was attempted

Fix the arguments

4

Findings need a decision

Decide, and then resume

Resume from the step that stopped, not from the beginning. The run names the step on the way out as STOPPED at <step>, and Step 3: What the Migration Runs, in Order lists the step names. How you resume depends on where the run was executing.

Step 3 runs in its own pod, and the pod stays in the Running phase whatever the outcome. The --hold option records the exit code to /tmp/exit-code and then sleeps, so the complete log survives long enough for you to copy it out. A failure therefore does not leave the pod in the Error phase, and the pod phase says nothing about what happened, so read the file. Either way, the pod cannot be re-run, and the command of a pod is immutable, so resuming means deleting the pod and creating it again.

To resume the migration from a stopped step:

  1. Delete the migration pod. The --ignore-not-found option makes this command work whether or not you already deleted the pod.

    kubectl -n "$NS" delete pod skylar-ch-ha-migration --ignore-not-found

  2. Create the pod again, with the --from=<step> option set to the step that stopped. The manifest is the same as the manifest in Step 3, except that it includes the --from option and omits the commented options.

    kubectl -n "$NS" apply -f - <<EOF
    apiVersion: v1
    kind: Pod
    metadata:
      name: skylar-ch-ha-migration
    spec:
      restartPolicy: Never
      serviceAccountName: skylar-sa
      containers:
        - name: migration
          image: ${IMAGE}
          command:
            - /home/runner/manual-scripts/2.8/clickhouse-ha-migration/pre-upgrade/run_migration.sh
            - --from=migrate                          # change to which step stopped
            - --yes
            - --hold                                  # stay alive so the log can be copied out
          env:
            - name: HELM_RELEASE_NAME
              value: "${REL}"
            - name: SNAPSHOT_CLASS
              value: "${CLASS}"
            - name: LOG_FILE
              value: /tmp/ch-ha-migration.log
            - name: WORKERS                             # lower if the resources below are not available
              value: "16"
          resources:                                  # equal requests/limits = Guaranteed QoS
            requests: { cpu: "1", memory: 2Gi }
            limits:   { cpu: "1", memory: 2Gi }
    EOF

If you work from a shell in the interactive pod instead, run the following command:

/home/runner/manual-scripts/2.8/clickhouse-ha-migration/pre-upgrade/run_migration.sh --from <step> --yes

You can re-run every step on its own. Each step derives its progress from ClickHouse state, not from a stored marker. An existing _backup database means resume. An existing table means skip its create. An existing partition means skip its attach. Starting over from the beginning is also safe: snapshot adopts an in-progress set instead of creating a second one.

Step 3: Dataviz Re-Coupling

The schema_sync job makes each dataviz <tenant>_reporting table an additional replica of the core table. It copies the SHOW CREATE statement of the core table, changes only the replica name, and pins the copy to the uuid of the core table. The migration mints new uuids, so every dataviz table ends up replicating a path that no core table feeds. The condition does not repair itself, because schema_sync issues CREATE TABLE IF NOT EXISTS, which matches by name only. The stale table stays forever, and reporting data silently stops reaching dataviz.

Dropping these tables is safe, because they are replicas, and core holds the same data. Superset is also not served from them. It reads the separate reporting database, which streaming_data_syncer fills from <tenant>_reporting, and which retains data much longer (400 days compared with 33). Dashboards keep serving history. What pauses is the feed into reporting.

This step runs in parallel across instances by default (--workers 10), capped by the instance count, so it adds nothing on a single-instance installation. It runs in parallel across instances only, never within one instance. Separate namespaces are separate ClickHouse servers that share nothing but the Keeper ensemble, whereas within one instance the drops contend on that server.

Every dataviz ClickHouse is named dataviz-clickhouse-shard0 with no release prefix, so a cluster-wide search for *-clickhouse-shard0 finds the core instance and all of the dataviz instances.

Steps 6 and 8: Why Two Helm Upgrades

HA only. The first run pins every heavy reader to replica 0 while replicas 1 through N-1 fill. The second run removes the override file and redistributes the pins.

The second run is required, not optional. Unlike upgrades/postgres-bitnami-migration.yaml, this override file does not correct itself. Until you drop it, every heavy reader stays on replica 0, and no read distribution exists at all.

The staging is needed because nothing in the stack stops a service from reading a replica that is still filling. Promotion to a pinned replica is connectivity-only, the readiness probe is httpGet /ping, which passes regardless of lag, and the headless service publishes not-ready addresses.

A partial read is not a stale read. The online analytical processing (OLAP) loop runs TRUNCATE on otel_logs_snap and refills it from what it reads. The evt_active_latest and evt_clr_latest tables are targets of materialized views only, so a partial read loses those events permanently.

Step 7: The Gate

HA only. The scripts/clickhouse-migration/2.8/await_ha_ready.py script runs on the post-upgrade hook at priority 999, after every other 2.8 step. A non-zero exit deliberately marks the upgrade as failed, because 2.8 is not complete while a replica is behind.

Reads are unreliable while the gate runs, not merely slower. The override file pins the heavy readers to replica 0, but anything outside those pins round-robins through the ClickHouse Service. The readiness probe is a bare /ping, which passes no matter how far behind a replica is. A replica that is still filling therefore stays in rotation, and a query that lands on it can return partial or empty results with no error at all. That silence is the hazard: an API that answers "no data" is indistinguishable from a genuine empty result. This hazard is also why the override file exists, and why Step 8 must not run until the gate is clean.

The duration is the initial clone. It depends on the data and the disk, and it can swing by about 5x depending on the IOPS and throughput of the receiving volumes. This variable is the largest in the whole procedure. The following table shows the effect.

Receiver Volume IOPS Throughput Clone About 1 TiB per Replica

StorageClass default

3,000

125 MiB/s

About 2.4 hours

Raised out of band

10,000

1,200 MiB/s

About 30 minutes

The receivers are the bottleneck, not the sender. Replicas 1 through N-1 provision brand-new volumes at scale-out, and neither gp3 nor skylar-persistence sets throughput or iops. The new volumes therefore come up at the baseline, while the sender might be running far faster.

Raise both values, not only the throughput. The clone is file-create heavy as well as byte heavy: about 39,000 parts is on the order of 1.7 million file creates, or about 570 seconds of I/O operations at 3,000 IOPS. That time is noise against a 2.4-hour transfer. After throughput alone brings the transfer to about 30 minutes, the file creates become roughly a third of the total, and the bottleneck moves to IOPS instead of going away. Setting allowAutoIOPSPerGBIncrease: "true" on the StorageClass does not help, because every default-provisioned volume sits at 3,000 IOPS regardless of size.

Nothing in this procedure raises these values. The right values depend on your environment, and they cost money while provisioned. You also cannot raise them in advance. Both StorageClasses use WaitForFirstConsumer, so the system creates and binds the PVCs for replicas 1 through N-1 only when Step 6 scales the StatefulSet out. Raise the values as soon as those pods appear. The volumes are brand new, so no prior-modification cooldown applies, and the change takes effect live while the clone is already running.

To raise the IOPS and throughput of the new replica volumes:

  1. Find the volume IDs for the new replicas. Only the receivers need this change, not pod-0.

    for pvc in data-"$REL"-clickhouse-shard0-1 data-"$REL"-clickhouse-shard0-2; do
      pv=$(kubectl -n "$NS" get pvc "$pvc" -o jsonpath='{.spec.volumeName}')
      printf '%s -> %s\n' "$pvc" "$(kubectl get pv "$pv" -o jsonpath='{.spec.csi.volumeHandle}')"
    done
  2. In the AWS console, go to EC2 > Volumes, select the volume, and then select Actions > Modify volume. Set the IOPS and the throughput together.

The gate joins the databases itself instead of waiting for the reconcile of tenant-service, which runs about every 600 seconds. A Replicated database is joined per replica by running CREATE DATABASE on that replica, and a replica that has not joined holds zero Replicated tables, so it could never satisfy the exit condition of the gate. A stale Keeper registration from a rebuilt replica fails this join with Code 253. The gate reports the failure and does not work around it. In that case, run SYSTEM DROP DATABASE REPLICA by hand.

The gate has no wall-clock deadline, because capping it would fail healthy upgrades. It does have a stall deadline: if nothing improves for the --stall-timeout period, the gate gives up and reports the stuck queue entries.

The gate heals exactly one fault. If a table in *_rptsource becomes readonly, the gate drops the table, and the loops rebuild it in about 57 seconds. A readonly table anywhere else blocks the gate until a person intervenes, because that data exists only on replica 0, and no loop can re-derive it.

Confirm that the gate fires. The gate is version-gated on previous_version < 2.8 <= current_version. If the appVersion of the umbrella chart is not bumped for the release, the registration evaluates to false, and the gate silently never runs.

Step 9: The Soak

Keep the soak short. Two conditions degrade while the backups exist:

  • Disk usage drifts upward.ATTACH creates hardlinks, so disk usage is flat at first. However, hardlinks share blocks only until either side merges, and the live side merges under normal ingest regardless.

  • Rollback fidelity shrinks. The backups keep applying TTL, so what they can restore gets older every day.

HA only. Watch monitoring-services/monitor. The following table lists the metrics and the values that you want.

Metric Want

clickhouse_ha_healthy

1

clickhouse_replica_readonly_tables

0

clickhouse_replica_rows_ratio

At or near 1.0 on every replica

clickhouse_replica_max_absolute_delay_seconds

Low single digits

The clickhouse_ha_healthy metric encodes unknown as absent, never as 0. A value of 0 means that a check genuinely failed. Alert on == 0, and separately, at lower severity, on absent_over_time(...). Scope the second alert to namespaces known to run HA, or it fires forever on single-replica installations.

Step 10: Dropping the Backups

This step is the last irreversible step. Until you run it, the _backup databases provide a fine-grained rollback: drop the new databases, rename _backup back, and the tables resume on their original Keeper paths. Afterward, the VolumeSnapshot is the only way back, and only until it expires.

The cost is per table, not per database. DROP DATABASE ... SYNC removes the znode of each table synchronously at about 1.2 seconds apiece, so about 1,746 Replicated tables take about 35 minutes if you drop one database after another.

By default, the script runs in parallel across databases (--workers 10), which brings the time down to roughly 5 minutes. The time is bounded by the largest single database instead of the total, because each DROP DATABASE is atomic in itself, and distinct databases touch disjoint Keeper paths. Use --workers 1 to force serial execution.

Expect two refusals, and both are correct:

  • A live table on a name-based Keeper path. The same-named backup computes the same path, so dropping the backup would remove the znode of the live table. The script refuses outright, with no --force override.

  • The max_table_size_to_drop setting. This setting is measured at 50,000,000,000 bytes (46.6 GiB), not unlimited. The script refuses any larger backup table on a per-table basis, which would otherwise leave a half-emptied database. The script detects this condition up front and names the remedies.

Rollback Details

The Helm rollback comes first because the restore reads its scale-up targets from the live StatefulSets. Restoring while the cluster is still scaled out leaves pod-0 on the pre-migration state beside pods 1 through N-1 on post-migration PVCs that no snapshot covers.

The rollback handles the following three things for you:

  • PVCs for replicas that the upgrade added. No snapshot predates these PVCs, and leaving them behind is not neutral. A StatefulSet binds any PVC that matches its volumeClaimTemplate name, so a later scale-out adopts post-migration data beside a pod-0 that was restored to an older state, and nothing reports the mismatch. The rollback deletes these PVCs after it flips their PVs to Retain. Use --keep-extra-pvcs to keep them.

  • The PVs that the rollback retained.Retain protects exactly one window: between deleting a PVC and rebinding it from the snapshot. Past that window, it only leaves Released PVs whose volumes nothing ever collects. On a clean run, the rollback sets each PV back to Delete and removes it, which frees the underlying volume. The rollback skips this cleanup when the run recorded failures, because the PVs are then the only copy of the pre-restore state. The --keep-released option also skips it.

  • Postgres. The rollback restores Postgres alongside ClickHouse and Keeper, because a rollback swaps images and not schema. Without the Postgres restore, data definition language (DDL) changes that a 2.8 migration applied survive into 2.6. The restore is deliberately not symmetric with ClickHouse. The postgresql-ha component is a repmgr cluster whose replication topology lives in the database, so the rollback restores the volume of the primary, and the replicas re-clone from it. Restoring Postgres also reverts the version history of the toolbox, which is harmless: a later re-upgrade re-runs the 2.8 scripts. The --skip-postgres option leaves Postgres untouched. If you want to keep the current Postgres data and fix only what stuck, drop the offending object by hand instead. For the one 2.8-era change that is already known, run the following statement for each tenant schema in the analytics database:

    ALTER TABLE alert_threshold_definitions
      DROP CONSTRAINT IF EXISTS alert_threshold_definitions_occurrence_window_pairing;

    That round trip is self-healing. Re-upgrading backfills a window for any row where N > 1 and re-adds the constraint.

The rollback does not cover the warm-up snapshot chain, and it cannot.

Restoring provisions new EBS volumes with new volume IDs, and incremental chains are per volume, so every earlier warm-up now points at a volume that no longer exists. A retry needs its warm-up run again, and that run is a full copy again, at roughly 5 GiB per minute of allocated data. Budget that time days ahead, not inside the window.

For more information, see the rollback/README.md file.

Cost Model

ATTACH PARTITION is a link() call per file plus one Keeper round trip. Data size is nearly irrelevant: a 21.93 GiB attach took 1.781 seconds, against 1.199 seconds for 583 KiB. What costs time is the number of partitions, so a larger estate is slower because it holds more partitions, not more bytes. The following formulas show the measured cost:

attach ≈ 1.08 s fixed + 0.116 s per part      (measured)
create ≈ 1.25 s per table in a Replicated database

Fixed overhead is about 75% of the attach time at a typical 3.2 parts per partition. Two consequences follow:

  • Parallelism is the only lever, which is why --workers defaults to 16. On the measured estate (39,277 parts, 12,080 attach statements, and 4,679 creates), serial execution takes 6 hours 31 minutes, against 24 minutes at 16 workers.

  • Do not run OPTIMIZE beforehand. It can touch only the remaining 25%, and it costs far more than it saves.

Verification Checklist

The following table lists the checks that confirm a successful migration.

Check Expected

system.databases engines, in scope

All Replicated, none Atomic

Tables that are not Replicated*MergeTree, outside the skip list

None

Live tables on name-based Keeper paths

None. 40_verify.sh refuses otherwise.

Per-database completeness against the backup

No tables short

HA only. Replicated tables per replica

Equal on every pod

HA only.clickhouse_ha_healthy

1

Dataviz _reporting tables

Recreated, with total_replicas = 2, sharing the Keeper path of core

Dataviz reporting database

Receiving new rows. The second hop is what dashboards read.

/clickhouse/tables/shard<N> subtree, after the backups are dropped

Empty on a fully migrated estate