Learn Labs
Monitoring & Operations

Upgrades and Runbook

A rolling upgrade under load, measured, and the runbook for the failures the drills found

A rolling upgrade under load

scripts/upgrade_drill.sh puts the cluster on 26.8.34.13, starts two writers and a reader through HAProxy, and upgrades to 26.8.36.3 one container at a time: the three Keepers first, then each ClickHouse node, waiting for it to answer and for its replication queue to empty before the next.

./scripts/upgrade_drill.sh
0 s60120180225keepersone at a timech-1 (109 s)restart2,603 parts to fetchch-2 (28 s)ch-3 (7 s)ch-4 (14 s)
traffic: writes 6220 ok, 1 failed; 311,000 rows acknowledged, 0 lost; longest write gap 5.1s at t=14s
traffic: reads 64653 ok, 0 failed; longest read gap 3.0s at t=43s
ch-1 26.8.36.3   ch-2 26.8.36.3   ch-3 26.8.36.3   ch-4 26.8.36.3

No acknowledged write was lost and no read failed. The one failed write and the 5.1 s gap came at t=14 s, while keeper-1 restarted: replicated inserts need Keeper, and a Keeper restart moves sessions.

ch-1 took 109 s, the others 7 to 28. ch-1 was answering queries 34 s after its upgrade began; 31 s of that was the old container shutting down gracefully (stop_grace_period: 60s). The rest was its replication queue: while it was down, the two writers' 100-row inserts made thousands of small parts on its peer, and system.part_log shows ch-1 then downloaded 2,603 parts and ran 331 merges for that one table. Small inserts cost again, this time on recovery. A node that is down longer, or a busier cluster, takes longer to catch up, so the upgrade waits for the queue, not just for the node to answer.

Rules that hold for every upgrade:

  • Same LTS line for a rolling upgrade (26.8.x to 26.8.y). Between major versions, read the backward-incompatible changes in the changelog, and check system.settings_changes: the 26.2 async_insert default in this book is exactly the kind of change that slips through.
  • Keepers first, followers before the leader, one at a time; then ClickHouse nodes, one replica per shard at a time.
  • Wait for SELECT sum(queue_size) FROM system.replicas = 0 before the next node.
  • Settings changes without downtime: most server settings in config.d/ and users in users.d/ reload without a restart; check system.server_settings (changeable_without_restart).

Runbook

Symptom / alertLikely causeDo
ClickHouseReadonlyReplicanode lost its Keeper sessioncheck Keeper (echo mntr | nc 127.0.0.1 9181 on each); inserts hang 142.8 s then fail until it's back
ClickHouseKeeperNoLeaderKeeper majority downrestore Keeper members; never wipe a Keeper's data to "fix" it
ClickHouseShardDownboth replicas of a shard downbring one back; queries fail until then (don't set skip_unavailable_shards)
ClickHouseTooManyParts, inserts slowmany small inserts, or merges blockedbatch inserts; check system.merges, free disk, system.replication_queue errors
ClickHouseInsertsRejectedparts over 3,000 in a partitionstop the small-insert source first, then let merges catch up
ClickHouseReplicationLagreplica fetching or stucksystem.replication_queue (last_exception); SYSTEM RESTART REPLICA if stuck
ClickHouseDistributedQueueBackloga shard was unreachablecheck system.distribution_queue last_exception; the files are only on that node's disk
ClickHouseMemoryNearLimitheavy queriessystem.processes; KILL QUERY; lower per-user max_memory_usage
disk fillingdata growth, failed mergesTTL, drop old partitions, add disk; inserts fail with code 243 at full

Common production mistakes this book measured

  • Single-row inserts from many places, now silently slower by default under async_insert (59 ms each from one client).
  • Retrying inserts that returned an error without deduplication: the quorum error still wrote every row.
  • Trusting skip_unavailable_shards: half the data, no error.
  • A quota behind a load balancer: counted per server.
  • Benchmarks without turning off the query condition cache.
  • A bloom_filter index on a column whose values are everywhere.

On this page