Runbooks
Reference, rendered from docs/chloedb/runbooks.md.
These docs follow main, which can be ahead of the latest release, 0.3.11 (its docs): a change made after it says so where it is described.
On this page
- Queries are slow
- Searches fail
- Queries are refused
- A copy is down
- A replica is behind
- A Postgres follower holds a table
- A connector fails or falls behind
- The disk is filling
- A disk reads slowly
- A node's disk nears Kubernetes' eviction line
- A statement times out
- Writes fail or queue
- Data damaged on disk
- A shard's primary changed
- A rollout is held
- Restore from checkpoints
- Upgrades outside Kubernetes
What to do when an alert fires or the fleet view names a problem, written
for an operator and for an agent alike. Each runbook names the alerts
(GET /v1/alerts) and fleet problems (GET /v1/health/fleet, each
problem's id) it is for, then the steps: what to read first, what an
ops key may do alone (tier 1), and what needs a person's approval (tier
2 and 3, filed as a change request with POST /v1/admin/changes). The
tiers are explained in chloedb-server.
The server compiles this page in: GET /v1/catalog lists the routes the
steps name, the MCP tool runbook finds a runbook by an alert's or a
problem's id (runbook {"for": "copy-down"}), and each fleet problem's
next.runbook names the one to read. The last section, on upgrading
servers outside Kubernetes, is for no alert.
Queries are slow#
For: p99, p99-jump, p99_recovered
- Read where the time goes:
GET /v1/queries/slow(toolqueries,which: slow) andGET /v1/queries/statsgroup the slowest statements by their fingerprint;GET /v1/loadshows each server's CPU and queue. - Read what changed around the jump:
GET /v1/events?from=<ms>(toolevents): a plan applied, a primary changed, a copy down, a rollout. - One statement or one key holding the cores (tier 1, an
opskey with a reason): limit it with a contain rule,POST /v1/admin/contain {"match": {"fingerprint": "..."}, "action": "limit", "concurrency": 2}(toolcontain); an agent's rule lasts an hour at most. - One query running for minutes (tier 1): cancel it,
DELETE /v1/queries/<id>(toolcancel_query). - The cluster is short of CPU for its load (tier 2): plan more copies or
shards,
POST /v1/admin/plan(toolplan_reshape), and file the plan as a change request.
Searches fail#
For: errors, availability, 5xx, error_ratio, error_ratio_recovered, partial-answers, key-failing
- Read which statements fail and where:
GET /v1/queries/recent?outcome=failedandGET /v1/logs?level=error(toolsqueries,logs). Each error answer carries anerror_code(GET /v1/cataloglists them):query_invalidandtable_not_foundare a client's,unavailableandinternalthe cluster's. - Errors of one client (
key-failing): tell the key's owner; nothing to change on the server. - Shards that do not answer (
partial-answers,unavailable): follow "A copy is down" below. - Errors after a change: read
GET /v1/eventsandGET /v1/admin/auditfor what changed, and file the change that undoes it (each dry run'sundosays which) as a change request.
Queries are refused#
For: rejected, query-memory, key-flood, contained
- Read what is refused and why:
GET /v1/queries(running now, grouped by key and statement) andGET /v1/admin/contain(the contain rules in force; toolcontain_rules). An answer refused by a contain rule has codecontained. - One key crowds out the others (tier 1): limit the key,
POST /v1/admin/contain {"match": {"key": "..."}, "action": "limit", "concurrency": 4}, and tell its owner. - A contain rule that refuses too much (tier 1): remove it,
DELETE /v1/admin/contain/<id>(toolremove_contain). - The load is real and lasting (tier 2): raise
--max-concurrentor--query-memory-mbin the spec (POST /v1/admin/kube/plan, then a change request), or add copies.
A copy is down#
For: copy-down, copy-silent, under-replicated, shard-no-majority, copies, shards, coordinators_gone
- Read which copy, since when, and what else happened:
GET /v1/health/fleet(toolhealth), thenGET /v1/events?kind=copy_down,primary_changedand the copy's own lines from the log stores,POST /v1/logs/query {"sql": "SELECT ts, level, message FROM logs WHERE node = '<copy name>' ORDER BY ts DESC LIMIT 200"}(on a coordinator it searches every copy's store;GET /v1/logshas the coordinator's own lines only). - A copy that restarts by itself (a pod killed for memory, a rollout):
wait for it,
GET /v1/events?after=<id>&wait_s=30answers as soon as its next event comes. Silence the alert meanwhile (tier 1, two hours at most for an agent):POST /v1/alerts/copy-down/silence {"minutes": 30, "reason": "s1-0 restarting"}(toolsilence_alert; the server refuses a silence without areason). - A copy that does not come back (tier 2): replace it.
POST /v1/admin/plan {"shards": [{"shard": <i>, "copies": [...]}]}, the gRPC URLs the shard keeps with the dead copy left out and its replacement in, plans the repair (Cluster: Plan the repair, in the command center); file the plan as a change request. A plan that adds a server is applied with the cluster's token, which the coordinator sends to it (403cluster_token_requiredwith the admin token or a key): on machines of your own, a person runschloedb-server admin --key "$CHLOEDB_CLUSTER_TOKEN" call POST /v1/admin/plan/apply @plan.jsonwith the same body; on Kubernetes the operator adds copies itself. - A shard with no majority takes no writes, and its copies cannot elect
a primary. Its searches go on while a replica that is up serves reads
(the shard's state is
no_writes); when the copy left is its primary, it serves no reads either (no_reads), since with failover a primary serves reads only while a majority of its copies answer. Bring a copy back, or remove the dead one (tier 2 for a replica,DELETE /v1/admin/shards/<i>/replicas; promoting by force is tier 3 and a person's alone).
A replica is behind#
For: replica-behind, out-of-sync, replica-reads, lag, follow-behind
- Read how far behind and why: the primary's
GET /v1/health(replication.replicas: each replica'sseq_no, how many transactions it isbehind, and whether it isin_sync; on/metrics,chloedb_replica_behind), andGET /v1/load(the primary's write rate, the replica's disk and CPU).GET /v1/clustersays each copy's role and whether it serves reads; itstxncounts the transactions of each process since it started, so it does not compare two copies.GET /v1/admin/followfor a follower cluster, Data > Connectors (followersinGET /v1/admin/connectors) for a Postgres follower. - A replica catching up after a restart: wait, with
GET /v1/events?after=<id>&wait_s=30, and silence the alert for the while (tier 1). - A replica out of sync must not become the primary: do not promote it. Replace it (tier 2: a plan and a change request) if it does not catch up.
A Postgres follower holds a table#
For: follow-table-held
A table chloedb-server follow-postgres could not write is held: it is not
followed (its rows stay as they were), the other tables are, and it is tried
again after 30 seconds, then twice as long each time up to 15 minutes
(postgres.md).
- Read which and why: Data > Connectors, or
GET /v1/admin/connectors(the follower'stable_stateswithstateheld, and itserror, which names the table, the column and the row's key); on/metrics,chloedb_follow_tables_heldandchloedb_follow_table_error_info. - Fix the cause where it is: a value ChloeDB refuses, in the row in
Postgres; a table without a primary key, by giving it one in Postgres
(
ALTER TABLE ... ADD PRIMARY KEY) or taking it out of the publication; a ChloeDB table someone made with a type that cannot read Postgres's values, by fixing it in ChloeDB. Changing data in Postgres is the owner's (tier 2: a change request). - Then wait for the next try (
retry_in_s), or start the follower again with--copy-table <table>to copy it now (tier 1): its rows stay readable throughout, and the other tables keep following.
A connector fails or falls behind#
For: connector-failing, connector-behind
A connector that fails writes no new rows into its table, so what reads the table (a dashboard, an alert rule on it) goes quiet rather than wrong.
- Read which and why: Data > Connectors, or
GET /v1/admin/connectors(each connector'shealth,state.last_errorandstate.failures; a Kafka connector'sstream, withlast_error,lagand each partition'slag); on/metrics,chloedb_connector_up,chloedb_connector_failures,chloedb_connector_behind_secondsandchloedb_connector_partition_lag_events. - A source that is down or refuses the connector's credentials: fix it
there, or the connector's secret (tier 2: a change request, since it
changes what the server reaches). A pull runs again on its schedule, or
now with
POST /v1/admin/connectors/<name>/run(tier 1); a Kafka connector tries its brokers again by itself. - A Kafka connector behind but streaming: the server writes slower than
the topics grow. Read the writes (
GET /v1/load, the alertswrite-queueandwrite-p99); a biggerbatchwrites more a time. Stopping it (POST /v1/admin/connectors/<name>/stop) loses nothing: it goes on from the offsets ChloeDB keeps, while Kafka still holds them.
The disk is filling#
For: disk-full, disk-critical, disk-filling, disk
- Read which tables grow:
GET /v1/tablesandGET /v1/load(each copy's disk). - Old rows a table keeps for a set time: a table made with a retention
(
retain) drops them on its own. A table's retention is set when it is made and cannot be changed (ALTER TABLE ... SET (retain = ...)is refused): for a table made without one, or with too long a one, make a new table with the retention, move the writers to it, and drop the old one once its rows are no longer needed (tier 2 and 3, change requests). - More room (tier 2): add disk in the spec (
POST /v1/admin/kube/plan), or add a shard and move slots to it (POST /v1/admin/plan), each filed as a change request. - Deleted or expired rows still on disk: a server that takes writes gives the
free space of its file back by itself, every 5 minutes, once 64 MB and a
sixteenth of the file are free (it moves segments from the end of the file
into free space below them and truncates the file; it needs no room and
loses nothing; not on a replica). Tables and storage shows the file
(
totals.file_bytesofGET /v1/index/tables) beside the tables' live data. When the free space is in pieces too small for the segments above them,POST /v1/admin/vacuumfrees them for good (tier 3: it loses old versions, and is a person's alone). It needs room first: the file grows while it runs, by what lies above its first free gap, which is written twice (in a persona study, a 1.4 GB file reached 2.5 GB before it shrank to 1.1 GB, and the process's memory 3 GB), so on a disk that is nearly full, free room another way first. Pages a statement freed become reusable two commits later: a vacuum straight after aDROP TABLEcan free nothing, and the next one frees them.
A disk reads slowly#
For: disk-slow, disk_speed
- Read what each copy's disk probe measured:
GET /v1/admin/disk?copy=<url>on a coordinator (probe.kept: the last hour's readings) and the problem'swhy. A disk far slower than its peers' that is not busy (disk_busylow) is the disk's fault, or the machine's under it (a degraded cloud volume or host), not the load's. - Measure again (tier 1, an
opskey with a reason):POST /v1/admin/disk/probe {"copy": "<url>"}. - The copy is its shard's primary, and another copy is in sync on a fast
disk: hand the primary over (tier 3, a person's),
POST /v1/admin/shards/<i>/promote {"url": "<the fast copy>"}, so that writes go to a fast disk. - Replace the copy (tier 2, and it costs money: a node or a volume): add a copy of the shard on another node or a volume, wait until it is in sync, then remove the slow one; plan it and file it as a change request.
A node's disk nears Kubernetes' eviction line#
For: disk-evict, disk-evict-now, evict
The database is on the node's own disk (a hostPath or an emptyDir),
which the kubelet shares: once that disk has less than its eviction
threshold free (15% on DigitalOcean, --evict-free-ratio), Kubernetes
evicts every pod of the node, the database's among them.
- Read what fills the disk:
GET /v1/admin/disk?copy=<url>lists the database's own files and every other entry beside them, the largest first, with when each last changed (a build's output, a copy left behind). - Delete what is not needed (tier 3, a person's: it loses data):
POST /v1/admin/disk/clean {"copy": "<url>", "paths": [{"path", "modified_ms"}]}with entries as the listing gave them. The server refuses its own files, anything changed since it was listed, and anything it did not list. Files outside the database's folder (images, other pods' files) are the node's: clean them on the node. - Move the database to a volume of its own (tier 2, and it costs money): a copy of each shard on a volume, in sync, then remove the copies on the node's disk.
A statement times out#
For: slow-statement, statements
- Read the statement:
GET /v1/queries/stats/<id>(its slowest calls, where it waits by shard, who sends it) and the problem'swhyandreads: a filter on a field the table neither indexes nor is clustered by reads every row of the table (reads.every_row). - One client sending it (tier 1, an
opskey with a reason): limit it with a contain rule,POST /v1/admin/contain {"match": {"fingerprint": "..."}, "action": "limit", "concurrency": 2}, while it is fixed. - A filter no index serves: the application reads a summary table kept by that field, or the table is made again indexed or clustered by it (tier 2, a change of the schema).
- A shard that holds it up, on a copy whose disk reads slowly: follow "A disk reads slowly".
Writes fail or queue#
For: failing, flush-failing, merge-failing, write-queue, write-p99, write_error_ratio
- Read the server's lines:
GET /v1/logs?level=erroron the server itself (a full disk, an I/O error), or through a coordinator, every copy's:POST /v1/logs/query {"sql": "SELECT ts, node, message FROM logs WHERE level = 'error' ORDER BY ts DESC LIMIT 100"}. - A database that refuses writes (
failing) on a primary: with--failover-after-msit hands its shard over to a replica in sync by itself; without it, hand the primary over first (tier 3,POST /v1/admin/shards/<i>/promote, a person's). Then fix the cause and restart the server. - Slow writes with
--write-acks all: a replica or its link is slow; follow "A replica is behind".
Data damaged on disk#
For: damaged
- Read which copy and which segments:
GET /v1/health/fleetandGET /v1/events?kind=damaged. - Verify again (tier 1):
POST /v1/admin/verify, which on a coordinator has every shard's primary compare its replicas (one shard:POST /v1/admin/copies/verify {"url": "<copy>"}). - Replace the copy (tier 2): plan the repair and file it as a change request; never make the damaged copy the primary.
A shard's primary changed#
For: primary-changed
- Read why:
GET /v1/events?kind=primary_changed,copy_downand the old primary's lines (POST /v1/logs/query {"sql": "SELECT ts, level, message FROM logs WHERE node = '<copy name>' ORDER BY ts DESC LIMIT 200"}). - Nothing to do when the old primary is back as a replica in sync; it resolves ten minutes after the last change. A handover asked by hand fires it too. Otherwise follow "A copy is down".
A rollout is held#
For: rollout, held
- Read what the gate saw:
GET /v1/kube(the operator's status and the gate's reason) andGET /v1/events. - When the reason is understood and the change is wanted (tier 2):
POST /v1/admin/kube/resume, filed as a change request; otherwise roll back (POST /v1/admin/kube {"rollback": <the version before>}), also a change request.
Restore from checkpoints#
For: restore, lost-data, bad-write
Rows were deleted or overwritten by mistake, or a shard's copies all lost their disks, and the cluster has to go back to its checkpoints. Restoring is a person's alone (tier 3): it stops the cluster and takes back every write since the checkpoint. These steps are for servers you start yourself (by hand, from systemd, in a container); on Kubernetes the operator keeps its pods running and has no restore step yet.
- Have checkpoints of every shard from one cluster map:
POST /v1/admin/checkpoint {"name": "nightly"}on the coordinator writes one on each shard's primary, into its--backup-dir, with the shard's cluster map (nightly.slots) and the cluster's API keys (nightly.keys.json) beside it, and answers theslot_epochthey are of. Copy the three files of each shard off the machine. A checkpoint of one copy isPOST /v1/admin/copies/checkpoint {"url": "...", "name": "..."}.GET /v1/admin/checkpointslists every copy's, each shard's newest, and undercompletethe names on every shard under one cluster map: the sets you can go back to. - Read what you are going back to: each shard's checkpoint names its
shard and epoch (
nightly.slots), andGET /v1/clustergives the epoch now (slot_epoch). Slots moved since the checkpoint when the two differ: then restore every shard, never one alone, or rows would be in two shards or in none. - Stop the coordinator and every copy of the shards you restore.
- On each copy, put its shard's checkpoint in place of its database:
chloedb-server restore --from /backups/nightly --db /data/shop.chloedb(with--keys FILEwhen the server has--keys FILE). It checks the checkpoint before it changes anything, moves the database's own files aside into/data/shop.chloedb.before-restore-<time>/, puts the shard's map beside it and merges the keys in (keys revoked since stay revoked). It refuses while a server has the database open and when the checkpoint is of another shard than the copy's. A copy on an empty disk is restored the same way, or started empty: its primary sends it every row, and the coordinator gives it the cluster map. - Start each copy with the flags it had (
--replicason the shard's primary,--replicaon the others, the same--cluster-tokenand--seq-no), then the coordinator with its--shards. - Check before you let writes in:
GET /v1/healthon the coordinator, andGET /v1/cluster, where each copy of a shard says the sameslot_epochand the sameseq_no, its replicas in sync, and the shards' rows add up to the checkpoint's (SELECT count(*)through the coordinator). The files moved aside can go once it does.
Upgrades outside Kubernetes#
On Kubernetes the operator rolls a new version through the cluster (upgrades). On machines of your own, upgrade one server at a time, waiting after each until the cluster is well again:
- In each shard, its replicas, one at a time: stop it with SIGTERM,
start it on the new binary without
--replicasor--replica(it takes up the part its<db>.replicationkeeps), and wait until its ownGET /v1/healthsaysreplication.serves_readsandGET /v1/clustersays every shardok. A replica must not be older than its primary. - Then hand the shard over to an upgraded replica (tier 3, a person's:
POST /v1/admin/shards/<i>/promote {"url": "<its gRPC URL>"}), and upgrade the old primary, now a replica, as the others. - The coordinators last, one at a time, each with
--drain-msbehind a load balancer.
Operate a cluster runs this on one machine, and versions and compatibility says what a cluster of mixed versions serves.