Error Codes

NodeDB uses NodeDbError — a struct with numeric ErrorCode, human-readable message, machine-matchable ErrorDetails, and optional chained cause.

Error Categories

Code RangeCategoryExamples
1000–1099Write pathConstraint violation, deadline
1100–1199Read pathCollection not found
1200–1299QueryParse error, plan error
2000–2099AuthAuthorization denied
3000–3099SyncDelta rejected, sync error
4000–4099StorageSegment corrupted, WAL error
5000–5099ConfigBad request, invalid config
6000–6099ClusterNo quorum, shard unavailable
7000–7099MemoryBudget exceeded
8000–8099EncryptionKey error, decrypt failure
9000–9099InternalUnexpected internal error

Common Errors

ErrorCodeResolution
COLLECTION_NOT_FOUND1100Check collection name
TYPE_MISMATCH1020Check data types in query
CONSTRAINT_VIOLATION1000Duplicate key on plain INSERT maps to SQLSTATE 23505 (unique_violation). Use UPSERT or INSERT ... ON CONFLICT DO NOTHING / DO UPDATE for non-error semantics.
DEADLINE_EXCEEDED1002Query took too long
INSUFFICIENT_BALANCE1022Not enough for TRANSFER
OVERFLOW1021i64 overflow on INCR
AUTHORIZATION_DENIED2000Check RBAC grants
SYNC_DELTA_REJECTED3001CRDT sync constraint failed

Database Boundary Errors

ErrorCodeResolution
DATABASE_NOT_FOUND1101Verify database name; check SHOW DATABASES
CANNOT_DROP_DEFAULT_DATABASE1102The default database is reserved; drop user databases instead

Database Quota Errors (7000–7099)

ErrorCodeResolution
SERVER_OVERLOAD7000Cluster under heavy pressure; retry with exponential backoff
TENANT_QUOTA_EXCEEDED7001Tenant's rate/concurrency/memory limit exhausted; reduce load or raise quota via ALTER TENANT … IN DATABASE … SET QUOTA
DATABASE_QUOTA_EXCEEDED7002Database's rate/concurrency/memory limit exhausted; reduce load or raise quota via ALTER DATABASE … SET QUOTA
QUOTA_OVERCOMMIT5001Sum of tenant quotas exceeds database quota, or database quota exceeds global; rebalance quotas
TENANT_VECTOR_DIM_EXCEEDED1023Vector embedding dimensionality exceeds tenant's max_vector_dim; reduce dimensionality or raise quota
TENANT_GRAPH_DEPTH_EXCEEDED1024Graph traversal depth exceeds tenant's max_graph_depth; reduce traversal depth or raise quota
SESSION_CAP_EXCEEDED7003Cluster session capacity exhausted; close idle sessions or raise max_active_sessions

Database Clone Errors (5000–5099)

ErrorCodeResolution
CLONE_DEPTH_EXCEEDED5002Clone lineage exceeds MAX_CLONE_DEPTH = 8; promote source clone to materialize and flatten lineage
CLONE_DEPENDENCY5003Source database has dependent clones; DROP clones first or use DROP DATABASE source FORCE to trigger materialization
CANNOT_CLONE_MIRROR5004Mirrors are read-only and create ambiguous bitemporal lineage; PROMOTE the mirror first, then clone

Database Mirror Errors (1100–1199, 6000–6099)

ErrorCodeResolution
MIRROR_READ_ONLY1103Mirror is read-only until promoted; use ALTER DATABASE <mirror> PROMOTE to switch to writable mode
STALE_READ_NOT_LEADER1104Strong consistency requested on a mirror (which is stale); use BoundedStaleness or Eventual consistency, or connect to the source database for strong reads
MIRROR_DEGRADED6001Mirror lag exceeds threshold (default: 5 s async, 100 ms sync); check source–mirror network and availability
MIRROR_DISCONNECTED6002Mirror disconnected from source; reconnecting with exponential backoff

Move Tenant Errors

ErrorCodeResolution
MOVE_TENANT_ALREADY_AT_TARGET5005Tenant already moved to target database; re-issuing is idempotent (safe to retry)

Session Lifecycle Errors (2000–2099)

ErrorCodeResolution
SESSION_REVOKED2001Session terminated due to identity change (DROP USER, role revocation, or soft-delete via is_active=false); reconnect to authenticate
SESSION_IDLE_TIMEOUT2002Session closed due to inactivity exceeding idle_session_timeout_secs; reconnect and keep activity
SESSION_NOT_FOUND1105KILL SESSION targeted a non-existent session ID; verify SHOW SESSIONS for active session IDs

Error Construction

Errors are created via constructors: NodeDbError::storage("detail"), NodeDbError::collection_not_found("users"), etc.