Skip to content

Troubleshooting

Mohammad Rasoul Kazemi edited this page Nov 26, 2026 · 2 revisions

Troubleshooting

Errors that an operator or an application meets, grouped by where they come from. Codes and texts are taken from the READMEs of the extensions, the README and contract of the control plane and the verifier. For procedures see Runbooks; for alerts see Monitoring and Alerts.

SQLSTATEs of kingres_shard

The extension's own class is KS. The codes follow what the caller should do, so several texts share a code. The full table, with the test of each code, is in the section "SQLSTATEs of the answers" of the extension README. KS003 is raised only inside the SQL loop of a cancelled bucket move, which catches it; no caller sees it. KS023 is the next free code.

SQLSTATE Meaning What to do
KS001 Stale bucket map: the statement was routed on an old map, a bucket moved, a group changed its primary, or a node failed while a distributed statement ran. Also a version difference of an extension between nodes during a pushed statement Retry. The origin reloads the map and repeats once when it can. A group that has a standby may be failing over
KS002 The catalog of the sending node is superseded by a newer catalog term Stop sending from that node; sync_catalog() brings it up to date
KS004 A bucket move gave up waiting for its switch Nothing: the move goes back to catching up by itself
KS005 A participant could not get its own standby to confirm that its part of a transaction is durable Fix the list of synchronous standbys or the standby, repeat. Nothing was committed
KS006 A planned switchover cannot be proven loss-free Treat the promotion as a failover
KS007 A node accepted the session and one statement of a control call was not answered within kingres_shard.node_timeout (default 60s) Do not repeat against that node blindly: it is a silent node. Check the node. A node that answers late but within the limit never causes it
KS008 Another call that changes the catalog is running and did not end within node_timeout Nothing changed; repeat later
KS009 The node cannot commit: its synchronous standbys do not confirm Fix the list or the standby, repeat
KS010 The call went to the wrong node (not the map group primary, a superseded one, a node that is not a standby of the map group, a wrong port) Send it where the message and hint say
KS011 The node to promote is still in recovery Promote it in PostgreSQL first, wait, repeat
KS012 Promoting would not be safe (a node holds a newer catalog term, or only a minority of the groups can be reached) Not a retry: a decision of the operator
KS013 Distributed transactions are in doubt Run recovery, wait until check_cluster() shows none, repeat
KS014 Two nodes hold cluster secrets that do not match The README table tells which node is behind; a standby that missed a rotation needs to catch up
KS015 The call took longer than kingres_shard.control_call_timeout as a whole (the setting is 0, no limit, unless set). Says nothing about any node Repeat with a longer limit or none
KS016 The table is a ledger table (or the history table of one) and is refused by create_distributed_table and create_reference_table Not a retry: keep it as an ordinary table
KS017 No shard group may receive buckets (no active primary has should_have_shards) Register a node or set shouldHaveShards; the control plane answers no_receiving_server
KS018 The sizes of the buckets of a group cannot be read, so a plan by disk size does not guess Repeat later
KS019 The bucket or its colocation group is busy for a split (another split or a table operation runs, or the bucket is not active) Wait for the other operation and repeat (bucket_busy)
KS020 The schema holds a ledger table and is pinned to its shard group: it cannot move or be undistributed Not a retry (schema_pinned)
KS021 The verification of a table operation failed; the old copy is kept Not a retry; the task fails with verification_failed
KS022 A catalog-changing function was called on a node that is not the map group primary Call it on the map group primary
55P03 A lock wait on a node ended because of a shorter lock_timeout Repeat when the other session is gone
25001 recover_prepared_transactions() or promote_node() was run in a REPEATABLE READ or SERIALIZABLE transaction Run it in READ COMMITTED, or give the control plane's role default_transaction_isolation = 'read committed'
40P01 Distributed deadlock victim Retry the transaction
55000 A mistake of the caller: a node that is not a standby, a node of another major or extension version, the library not loaded, "not initialized" Fix the input
0A000 A feature of a single node that a distributed statement does not support; a pushdown path that stays closed See Sharding Query Pushdown and Limitations and Known Issues

A WARNING that names a node can carry the SQLSTATE of the reason (KS007 for a node that stopped answering); a program can tell it from a warning that only informs. Cluster checks: kingres.check_cluster() reports inconsistencies (for example server_major_differs, table_verification_failed).

SQLSTATEs of kingres_ledger

SQLSTATE Meaning
KL001 Modification (update or delete) of an append-only ledger table
KL002 A statement rejected by the protection hook or the event trigger (for every role, superusers included)
KL003 The library is not in shared_preload_libraries; ledger_enable refuses to run
KL004 The previous block is closed ahead of the clock
KL005 The SQL of the extension is older than the library. Hint: ALTER EXTENSION kingres_ledger UPDATE. See Upgrades
KL006 A call that would take a lock out of the documented order
KL010 A transaction leaves an entry of a table whose signature policy is required without an attestation (at COMMIT and at PREPARE TRANSACTION)
KL011 ledger_attest finds no such entry in this transaction, or every one is attested
KL012 The client key is unknown, revoked or not allowed for the role
KL013 The signature does not verify
KL014 The nonce was used with that key before
42501 A write to the ledger's own tables that only the code of the ledger may make (insufficient privilege)
0A000 ledger_attest on a server built without OpenSSL

The extension must be preloaded, and its owner must be a superuser. See Ledger.

Other extensions

Extension SQLSTATE Meaning
kingres_columnar 40001 A snapshot older than a rewrite (TRUNCATE, SET ACCESS METHOD, a rewriting ALTER TABLE) reads the table: the read fails and names the rewrite
kingres_columnar XX001 Accidental damage found when a chunk is read (page and stripe identity, footer CRC, a CRC-32C of every chunk), independent of data checksums
kingres_columnar 0A000 Refusals of what columnar storage does not support (for example CLUSTER; creating or writing a columnar table when the library is not preloaded, with a message that names shared_preload_libraries)
kingres_timepart 0A000 conversion_refused: <reason> when a partition cannot be converted and its reason names what cannot be carried
kingres_timepart 55P03 schema_changed: the partition was renamed or dropped while the conversion waited; retryable and changes nothing (a policy run is due again within five minutes)
kingres_sketch 54000 program_limit_exceeded: the aggregate states of one backend would pass kingres_sketch.state_memory_limit or the ceiling

See Analytics Extensions.

Problem codes of the REST API

Every error is application/problem+json (RFC 9457) with type, title, status, detail, instance and a stable code. Clients branch on code, never on the text; the response carries X-Request-Id, copied into requestId and into the audit event. Unknown codes must be tolerated. By status (the full list is ProblemCode in the contract):

Status Codes and what they say
400 bad_request, validation_failed (a value not valid for its parameter)
401 unauthenticated, invalid_credentials, session_expired, setup_token_invalid
403 forbidden (missing cluster role, or a role the data transfer refuses), csrf_token_invalid, data_transfer_disabled, insecure_transport (the data transfer needs TLS)
404 not_found, config_parameter_unknown
405 method_not_allowed (with an Allow header)
409 conflict, already_exists, immutable_field, rebalance_in_progress, operation_in_progress, task_not_cancellable, last_admin, role_in_use, optimistic_lock_failed, no_replica_available, instance_already_running, instance_already_stopped, server_owns_buckets, server_hosts_map_group, last_server, server_group_not_empty, ledger_entry_pending, certificate_revoked, internal_api_disabled, nothing_to_rebalance, rebalance_not_running, cluster_inconsistent, version_mismatch, failover_in_progress, group_degraded, no_receiving_server, failover_needs_decision, lease_settings_differ, ledger_not_published, origin_prefix_locked, signing_key_missing, last_signing_key, chain_not_diverged, config_change_superseded, config_restart_order_conflict, nothing_pending, insufficient_disk, replicas_cannot_be_kept, sharding_mode_in_use, schema_pinned, bucket_busy, extension_version_mismatch, extension_missing, conversion_refused, partition_policy_conflict, transfer_quota_exceeded, upload_incomplete, upload_offset_mismatch
422 unprocessable, sql_error, node_state_invalid, config_parameter_managed, config_parameter_refused, config_level_not_allowed, config_value_below_floor, table_not_eligible (the blockers name why), schema_not_distributable, split_unsupported, extension_unavailable, upload_checksum_mismatch, import_header_mismatch, import_too_large, export_untrusted_code, export_not_readable, large_objects_present, schema_unrecognised, archive_invalid, archive_statement_refused, ledger_restart_not_acknowledged, and unsupported_operation (a request that this server cannot run; every operation of the contract is built)
413 chunk_too_large (an upload chunk)
429 rate_limited (unauthenticated endpoints), workbench_busy (a role already runs its two workbench statements, or the server four; has Retry-After)
503 node_uninitialized, map_group_unavailable, leader_unavailable (the field serverIds names servers to open instead), quorum_unavailable, service_unavailable, system_database_stopped (start it with startThisServerInstance), certificate_authority_unavailable
500 internal_error

A 409 failover_needs_decision carries the plan in Problem.plan. The list above is the contract's ProblemCode; a few more codes (for example schema_move_in_progress, sketch_hash_mismatch, import_ledger_policy, import_end_marker, archive_incompatible) are in the enumeration and are described at the operations that return them.

Symptoms and actions

Symptom Likely cause Action
Panel unreachable from another machine The panel listens on 127.0.0.1:8091 by default Use an SSH tunnel, or set KINGRES_LISTEN and TLS in /etc/kingres/kingresd.env; see Configuration
Setup from another machine refused Remote setup is off KINGRES_ALLOW_REMOTE_SETUP=true; the setup token is still required
401 setup_token_invalid or setupTokenRejected in the audit Wrong or used token Read /var/lib/kingres/setup-token on the server
Setup stopped half way, secret_unavailable The administrator password exists only in the request that started the task Call POST /api/v1/setup/init-cluster again with the same data directory and token; to start over remove instances, service-credentials, setup-task.json and node-state.json
503 node_uninitialized on every call The node is not yet part of a cluster (also for about four seconds after a server left) Run setup or join; see Cluster Setup
503 leader_unavailable A follower has not heard the manager leader for longer than 30s Open one of the servers named in serverIds; check the leader's server
503 system_database_stopped The instance that hosts the system database was stopped on purpose startThisServerInstance
409 rebalance_in_progress or operation_in_progress A rebalance and a server task exclude each other Wait, stop the rebalance, or cancel the other task
409 server_owns_buckets on removeServer or leaveCluster The server still holds buckets Move them off by rebalance first; see Rebalancing
kingres-psql cannot connect over the Unix socket kingres-psql looks in /tmp, the socket is in /run/kingres/1 Use TCP (-h 127.0.0.1) or -h /run/kingres/1
Login from another address refused No access rule Add a rule in the panel's network access page
Creating or writing a columnar table is refused, or a conversion answers extension_missing The instance runs without kingres_columnar: the library file is missing, or the instance made by an earlier package has not been restarted since kingresd rewrote its preload list Check SHOW shared_preload_libraries; restart the pending instances (standbys of a group before its primary; the Configuration page of the console lists the restarts); see Installing and Packaging and Analytics Extensions
KL005 after a package upgrade The extension SQL of the database is older than the new library ALTER EXTENSION ... UPDATE for each extension; see Upgrades
Installing the other major's package is refused One package, one major per system There is no procedure to move between majors; see Installing and Packaging
Container reachable from other machines The image listens on 0.0.0.0 inside the container Publish the ports on 127.0.0.1 or a private network only; see Installing and Packaging
A drain, rebalance, server change or shouldHaveShards/weight change answers 409 operation_in_progress A database import is pending, running or paused Let it finish, resume it with the same import request, or cancel it; do not switch over or drain during an import (Backup Restore and PITR)
A database import fails at its last step with transfer_leader_changed A primary of the cluster changed during it (failover or switchover) Restore the preferred primaries if needed and run the import again
Export or import answers 403 data_transfer_disabled or insecure_transport The transfer is off by default and needs TLS Set dataTransfer.enabled (Settings page) and start kingresd with tls-cert-file and tls-key-file
ledgerSignerUnavailable with subject published-state The system database was restored and holds less than was published Follow the restore runbook (Runbooks)
extensionSkipped alert An extension was not installed on a server because a tenant role owns its schema See the operator guide, section 10; adding the server again re-applies it
versionMismatch alert Servers run different versions Bring the servers to one version; rebalance and failover refuse with version_mismatch
clockDifference alert A server's clock is off Fix NTP or chrony; kingresd does not set the clock; a key task also refuses with clock beyond two minutes
certificateRenewalFailed or certificateExpiring See Runbooks Renew by hand with renewServerCertificates
kingres-verify exits 3 The publication did not contain something that was asked for Not a pass. Treat as an alert; see below
A moved bucket or failover causes KS001 repeatedly The map keeps changing Retry; check check_cluster() and the failover status

Exit statuses of the verifier

kingres-verify statuses: 0 everything asked for was verified; 1 a verification failed (the failed step is named) or the thing under test cannot be parsed; 2 a usage or input error (a flag, a file you named, a trust file that cannot be used); 3 incomplete: nothing failed but the publication lacks something that was asked for, and VERIFIED is never printed; 4 a fork or rollback was found and the conflicting checkpoint could not be saved (as serious as 1); 5 only release verify: the set is genuine but was made by a dry run, not a release (--accept-dry-run gives 0). Treat 3 as an alert, never as "probably fine". Anchor checks without the inputs the auditor must supply also end in 3. See The Verifier.

Where to look

  1. The alerts and the failed tasks (GET /api/v1/alerts, GET /api/v1/tasks).
  2. journalctl -u kingres for kingresd, and the instance log under /var/lib/kingres/instances/1/pgdata/log/.
  3. The audit log (GET /api/v1/audit).
  4. SELECT kingres.check_cluster() on the map group primary.

Sources

Clone this wiki locally