Repository navigation
Runbooks
Procedures for the situations an operator meets. Every step comes from the operator guide, the README of the control plane or the REST contract, and uses operations that exist in the contract (kingres/api/openapi.yaml, 0.34.0) and pages of the console. Where the sources document no procedure, the runbook says so and does not fill the gap. Failover is new in the first release, 0.1.0 (2026-11-28): test your recovery procedure on your own cluster before you rely on it (High Availability). Alerts named here are described in Monitoring and Alerts; error texts in Troubleshooting.
All REST calls need a signed-in session with the role named in the contract; changing operations are audited (REST API Reference). The console pages named below are the ones of the console router: Dashboard, Servers, Server, Databases, Database, Table, Shards, Replication, Rebalance, Security, Ledger, Workbench, Tasks, Alerts, Logs, Settings, Configuration and This server (Web Console).
State: built (High Availability); test it on your own cluster first. The console has it on the Servers page (fail a server over) and the Replication page.
- The manager leader raises
serverSuspectaftersuspect-timeout(default 5s) without heartbeats, thenserverDownafterfailure-timeout(default 10s). The leader is the server that runs the primary of the map group; if that server is the lost one, see the map group case below. - Decide whether the server is lost or only unreachable. Nothing in the sources says how long to wait; automatic failover (off by default) waits for
max(timeoutSeconds, 3 x failure-timeout), a strict majority of servers reporting it not live, and no failover in the last 5 minutes. - Look at the plan without changing anything:
POST /api/v1/servers/{serverId}/failoverwithmode: hardanddryRun: trueanswers 200 with the plan. - Fail over for real with
mode: hard. A request that could lose asynchronously replicated writes is refused with 409failover_needs_decision(and the alert of that name) until the request saysallowDataLoss. That is a decision of the operator, not a retry. One group at a time, the map group last; one failover at a time in the whole cluster. Servers that run different versions ofkingresd(alertversionMismatch) refuse it withversion_mismatch; finish the upgrade first (Upgrades). - Follow the task (
GET /api/v1/tasks/{taskId},GET /api/v1/failover) and read the report (GET /api/v1/failover/reports). Check the alertsfailoverDataLoss,splitPromotion,oldPrimaryRunning. - When the server returns, its old primary is made a standby of the new primary by itself:
pg_rewind, or a new base backup when the WAL it needs is gone; only a directory proved to be a former primary is touched. WatcholdPrimaryNotRebuilt(after ten minutes or half ofstandby-replace-after, default 30m). - If the server never returns, after
standby-replace-afterits standby records are marked for removal and replacements are made on other servers (a dead server gets no new standby). Removing the server itself (removeServer) is refused for adeadserver (422node_state_invalid: fail it over first), for the last server, for a server that holds an instance of the map group and for a server that still owns buckets (409server_owns_buckets). The sources do not describe removing a lost server that still appears in the bucket map; checkGET /api/v1/replication/topologyafter the failover. A server that owns buckets cannot be removed (rebalance first, or drain it:POST /api/v1/servers/{serverId}/drain). Right after a rebalance emptied the server,removeServerforces the cleanup of the moves of its groups that are still in the cleaning phase and waits for about two minutes while one of them is still cleaning (the task says what it waits for); it no longer fails with SQLSTATE 55006 when another cleanup holds a move at that moment. If it still fails, repeat the request. - To give groups back to their home servers once the failed server returned:
POST /api/v1/replication/restore-preferred-primaries(also withdryRun).
The map group. A failover of the server that runs the primary of the map group is started in mode hard and run by a standby of group 0 from a journal that survives a restart of kingresd. If the escrow of the certificate authority key was switched on beforehand (the Certificate authority tab of the Security page; it is off until an administrator switches it on), the new leader opens its own copy and goes on. Without it the new leader holds no key of the certificate authority and raises certificateAuthorityUnavailable until the operator restores pki/ca.key and pki/revoked.json of the old leader from its backup into the pki directory of the new leader and restarts kingresd, so a backup of the key must exist. Until then no certificate can be issued, renewed or revoked, addServer, joinCluster, removeServer and leaveCluster answer 503 certificate_authority_unavailable, and the cluster keeps running on its certificates until they expire.
The map group while its server is alive. mode: hard for the server that runs the primary of the map group also works while that server answers (a failing disk, a postmaster that hangs): the leader judges the loss, fences its own primary and hands the lease to a standby's server. Ask for dryRun first. Accepting a loss of data (allowDataLoss) in this request needs kingres_admin.
The candidate of the map group dies. If the standby that was handed the map group dies, the bootstrap cannot finish and the old leader stays held back. Declare it lost: POST /api/v1/failover/map/abandon (kingres_admin) with reason and lostServerId (the failover dialog of the map group in the console has a field for it). The lost server must have been silent for the failure timeout, and the old leader must hold a current cache of the administrators' keys (younger than admin-keys-max-age, 72 hours by default). With only one standby of the map group every REST call answers 503 and the declaration cannot work; the way out is the local command on the server of the old leader, with kingresd stopped: kingresd -release-map-hold -lost <serverId> -accept-data-loss (plus the settings of the server, at least -data-dir and -server-host). It is your word that what the lost server may have promoted is given up and that it never starts again with its old data directory; remove it from the cluster afterwards. The operator guide (section 6) has the details. If the abandon answers 503 with Retry-After, a promotion, a create, a remove or a rebuild of a standby is running on the server that holds the bootstrap (the abandon waits at most 25 seconds for it); wait for the time in Retry-After and repeat the call. The same 503 comes back when you call another server and it forwarded the call. When the bootstrap that you gave up was asking for the fence or holder lease, it lets the lease go, so the old leader wins it again and a drain that waited for it goes on.
State: built (High Availability).
-
POST /api/v1/servers/{serverId}/failoverwithmode: graceful, first withdryRun: true. For the server that runs the primary of the map group it is a planned switchover too, with the map group last; read the task from the new leader. Do not run a planned switchover, and do not restore preferred primaries, while servers of two versions run (Upgrades). - For each group the task pauses the writes, lets distributed transactions end, stops the old primary cleanly, proves that the standby replayed everything, then promotes it. The pause of writes is not kept across a restart of
kingresd. - A failure before the promotion rolls back (the old primary takes the writes again) and the task ends
failedwithstandby_behind,switchover_unproven,cannot_quiesceorprepared_transactions_pending. Read the code, fix the cause (a lagging standby, open prepared transactions), start again. The task can be cancelled (POST /api/v1/tasks/{taskId}/cancel) until the promotion begins. - If a switchover task fails, check the old primary (is it writable, did the writes resume) before you continue. A stop that takes longer than the call allows (90 seconds) is rolled back and the task ends
switchover_unproven; this is more likely under heavy machine load, so repeat the request when the load is lower. A task that is paused after the promotion with the critical alertfailoverBlockedand a message that a step "cannot read" a catalog is waiting for an instance that was starting or stopping: check that the instance named runs, then repeat the request to run the step again. If the map group is stuck,POST /api/v1/failover/map/abandongives up the bootstrap (for a planned switchover the old leader rolls back).
The monitor raises diskSpaceLow at 90% (warning) and 95% (critical) of the data disk. The sources document no procedure for a full disk; the contract reserves a problem code insufficient_disk for a later increment, and the README of the control plane says the free-disk check of a rebalance is not verified on real servers. What the sources do say:
- A standby whose replication slot holds more WAL than the warning limit raises
replicationLagHigh; the slot is dropped at the retention limit and the standby is then rebuilt. - The instance log is under
/var/lib/kingres/instances/1/pgdata/log/in a package install and is rotated by weekday. - The audit log rotates at 64 MiB and its segments are never deleted.
- A rebalance can plan by disk size (
byDiskSize) and a server can be emptied with a drain (POST /api/v1/servers/{serverId}/drain, preview with.../drain-preview), then removed (Rebalancing). The contract names the codeinsufficient_diskfor a bucket move or split and for an export or import that does not find room. - A drain handing over the map group, an import and an export need free space on every server; the import compares the expanded archive with the free space of every server before it starts.
Anything beyond that (adding a disk, moving data) is ordinary PostgreSQL administration that this documentation does not cover.
State: built (Rebalancing). A run makes one move at a time. The Rebalance page of the console shows it.
-
POST /api/v1/rebalance/stopstops it: the move in flight is cancelled (undone before the switch; a move that is switching is waited for), the run is recordedstoppedand the task ispaused.POST /api/v1/rebalance(startRebalance) goes on with the same task. A stopped rebalance does not blockupdateServerandremoveServer. - A failed move is retried after 30 s times its failures, up to three tries; a bucket given up ends the run
failed, the report is written first and the alerttaskFailedcarries the task. Read the report (GET /api/v1/rebalance/reports/{reportId}). - Moves skipped because a lease was lost, a required synchronous standby was not in sync or the target disk was low are in the report and are not failures.
- A rebalance cannot run while a
server.add,server.remove,server.leaveorserver.failovertask is unfinished, and the reverse; a start is then refused with 409. It is also refused while a database import is unfinished, while servers run different versions (version_mismatch), and (withoutforce: true) while a standby lags by more thanmaxStandbyLagBytes(group_degraded). A failed automatic run raisesrebalanceFailedand suspends the automatic mode until an operator starts a rebalance. - After a restart of
kingresdor a change of leader the new leader takes the task over and settles a move leftrunningthrough the extension (resume_bucket_moves()). The cancel of a task (cancelTask) stops a rebalance like a stop and records the runcancelledwithout ataskFailedalert. - An instance created before
wal_level = logicalwas written needs a restart; the check says so.
State: built; the CA itself is not rotated.
- The renewal job of each server renews its certificate when less than
certificate-renew-fraction(default 0.3333) of its lifetime is left. After three failures in a rowcertificateRenewalFailedis raised. - To renew by hand:
renewServerCertificates(POST /api/v1/servers/{serverId}/certificates/renewals, rolekingres_admin, taskcertificate.renew). It is the way for a server whose own job cannot (an expired certificate cannot call the leader; the leader can still call it). It is 409certificate_revokedfor a revoked server. - If the alert is
certificateAuthorityUnavailableor the renewals answer 503certificate_authority_unavailable, the leader does not holdpki/ca.key: restore it as in the map group case above. - The certificate of the cluster CA itself is not rotated.
certificateExpiringwith the aspectcawarns one year before the end and is critical 30 days before. The sources document no procedure for replacing the CA. - The public certificate of the panel (
tls-cert-file) is the operator's own and is not touched by the renewal job.
To lock a server out: revokeServerCertificates (.../certificates/revocations, task certificate.revoke). The internal API of every server and the PostgreSQL instances then refuse it; open connections run until they end. It never gets a new certificate. A server that owns no bucket is removed with removeServer and added again with a new setup token. Revoking a server that owns data is a one-way door in that version. The certificates of the leader cannot be revoked.
The system database kingres_system (schema kingres_cp) is on the map group (Data Model System Database). There is no automated backup: you take the backup (Backup Restore and PITR). What the sources state about a restore:
- After restoring it, restart every
kingresdof the cluster. The manager leader raises the term of the ledger when it takes over; writes of the ledger key set from the old term fail until it has. - The tiles, checkpoints and anchor records for the chains are public data derived from the chains and from keys the host still has. The aggregate log and the events cannot be derived again.
- Each holder of the key files keeps
published.json, the highest size and root of every log. A database that is behind it signs nothing and raises the critical alertledgerSignerUnavailablewith the subjectpublished-state, which says what was published, what the database holds, and a confirmation of sixteen hexadecimal digits. An operator accepts the loss (ADR 0025): check that the database really was restored and that no newer backup exists; on the host of the manager leader write the confirmation, and on a second line a reason of up to 200 printable ASCII characters, into<ledger-keys-dir>/accept-restore. The leader keeps the old record aspublished.json.before-restore-<generation>, replaces it by what the database holds, and publishes the signed eventrestore-acknowledgedbefore it signs anything else. There is no REST operation for this. The logs fork against a mirror that holds the old checkpoints; the event is the public statement of that. - Put the key directory (
ledger/keys, default<data-dir>/ledger/keys) and the passphrase file back from backup beforekingresdstarts. A startedkingresdthat finds no key for an active key row raisesledgerSignerUnavailableand signs nothing. - The CA key and
pki/revoked.jsonare files in the data directory, not in the database; they need their own backup. - A restore to an earlier state of a chain is a fork of the ledger: see the next runbook.
State: built (Ledger Signing and Publication); the Ledger page of the console has the acknowledgement.
The alert ledgerChainDiverged (critical) means the head of a chain is lower than what was published, or a published block changed: a restore of an older state, a point-in-time recovery, blocks lost in an asynchronous failover, or tampering. The ledger cannot tell which. Nothing is signed over that chain, nothing repairs it, and the database keeps working; other chains keep being published.
- Establish what happened (a restore you made, a failover with
allowDataLoss, or something you cannot explain). If you cannot explain it, treat it as an incident: the published tiles and any anchors hold the old history. - If the cut was intended or unavoidable, acknowledge it:
acknowledgeLedgerDivergence(POST /api/v1/databases/{databaseName}/ledger/chains/{shardGroupId}/acknowledge, rolekingres_admin). The body gives akind(restore,failoverLossorother), a reason and the database name as confirmation. It answers 409chain_not_divergedwhen there is nothing to acknowledge. - The task
ledger.epoch.startpublishes a signedepoch-closedevent (with the final size and root, the common height, the kind, the reason and who acknowledged it), freezes the old log for ever, starts a new epoch log built from block 0 of the current chain, and clears the alert. Anchors continue with the next aggregate checkpoint. - A verifier compares the two epochs and reports that the history was cut, when and by whom;
--accept-epoch-closedprints the finding and does not hide it (The Verifier). - A
pg_dumpand restore is not a restore of the chain: it gives an empty ledger with a new chain identity.
State: built (Ledger Signing and Publication); the signing tab of the Ledger page of the console has these actions.
-
Back up first. Back up
<ledger-keys-dir>and the passphrase file separately and off the cluster whenever a key is created or rotated. The console shows a reminder (backupAdvised) until the operator ticks that a backup was made; the tick proves nothing. -
Create or rotate:
createLedgerSigningKey(POST /api/v1/ledger/signing/keys). With an active key the call is a rotation; the new key is given to the servers that may become the leader (the leader and the servers that run shard group 0), a signedkey-addedevent is published, and the latest checkpoint of every log is signed again. A holder that cannot be reached gets the key later (jobledger.key.sync). One key task runs at a time in the cluster. -
Retire (the key is no longer used and its past signatures stay valid):
retireLedgerSigningKey(.../keys/{fingerprint}/retire). The key is bound to a maximum tree size, so what it signed stays valid and anything it signs later is refused. Refused with 409last_signing_keywhen no other key is active and in force. -
Revoke (the key is compromised):
revokeLedgerSigningKey(.../keys/{fingerprint}/revoke) with the date it is compromised since. It needs another active key (the control plane never makes one inside a revocation), publishes a signedkey-revokedevent, signs again and deletes key files no server needs. -
After a change, give auditors a new trust file from
getLedgerTrustFilethrough a channel outside the cluster; verifiers pin the trust file, not the database. -
All copies of the key lost with no other active key: the chain and the published history are not harmed but nothing more can be signed. The design offers "Replace lost key" in the console: a new key signs a
key-addedevent alone, the key ring is markeddiscontinuity: true, and every auditor must replace their trust file out of band. - A key task fails with a code such as
key_set_damaged,clock(retryable; the clocks of the server and of the database differ by more than two minutes),term_over,not_leader,key_files_remainorkey_file_missing. The alertledgerSignerUnavailableshows a damaged set or a missing file. - Client signing keys of a database (
registerLedgerClientKey,revokeLedgerClientKey) are separate and are described in Ledger.
leaseLost (critical): no majority of servers renewed the lease of a group in time. With a standby the primary was stopped so that no second primary exists; the instance does not start again without a lease. Without a standby the primary keeps running and writes are not protected by a lease. The sources document no manual step beyond looking at the cluster (check_cluster() in the extension, the failover status) and, if a server is gone, the first runbook.
oldPrimaryRunning, oldPrimaryNotStopped: kingresd stops an instance whose role file says primary on a port that the catalog calls a standby (checked every 2 seconds) and the lease keeps the old primary from acting. If the alert stays, the sources document no manual command.
- kingres/docs/guide/operator-guide.md
- kingres/docs/adr/0025-restore-of-the-system-database-is-accepted-by-an-operator.md
- kingres/control-plane/README.md
- kingres/api/openapi.yaml
- kingres/docs/design/ledger-phase7.md
- kingres/docs/design/ha-phase5-part2.md
- kingres/docs/reviews/2026-11-20-kingresd-failover-increments-4-7.md
- kingres/docs/reviews/2026-11-20-kingresd-anchoring-wiring-and-publication-fixes.md
- kingres/README.md
- kingres/packaging/README.md
- contrib/kingres_shard/README.md
KingresDB's own code is licensed under AGPL-3.0-only. PostgreSQL code keeps the PostgreSQL License. Copyright of the project's own code: RooyeKhat Media Co. KingresDB is derived from PostgreSQL and is not endorsed by the PostgreSQL project. Repository | Licence | COPYRIGHT
KingresDB
1. Product
- Product Overview and Features
- Status and Roadmap
- User Guide
- Administrator Guide
- REST API Reference
- Web Console
- Command Line Client
- Extensions
- Limitations and Known Issues
- Release Notes
Features in detail
- Sharding
- Sharding Query Pushdown
- Sharding Table Lifecycle
- High Availability
- Ledger
- Ledger Signing and Publication
- Ledger Anchoring
- The Verifier
- Analytics Extensions
Administration
- Cluster Setup
- Servers Databases and Roles
- Rebalancing
- Configuration
- Memory and Warm-up
- Control Plane and REST API
- Upgrades
2. Architecture (arc42)
- Architecture
- Architecture Introduction and Goals
- Architecture Constraints
- Architecture System Context
- Architecture Containers
- Architecture Components
- Architecture Runtime Views Sharding
- Architecture Runtime Views Availability and Ledger
- Architecture Deployment
- Architecture Crosscutting Concepts
- Security Model
- Architecture Decisions
- Architecture Quality Requirements
- Architecture Risks and Technical Debt
- Enterprise Architecture
3. Data architecture
- Data Architecture
- Data Model Sharding
- Data Model Ledger
- Data Model System Database
- Data Model Analytics
- Data Lifecycle
- Backup Restore and PITR
- Data Security
- Data Quality and Integrity
4. Development
- Building from Source
- Development and Testing
- Repository Layout
- Coding Standards
- Branching and Synchronisation
- Testing Strategy
- Review Process
- Release Process
- Contributing
5. Operations