Day-2 Operations, Prometheus Monitoring, and Error Catalog

Updated:
Author: Erkin Khidirov

The administrative plane of Slyber DB is built for zero-downtime maintenance across standalone servers and Multi-Raft clusters: secret rotation, node draining, partition rebalancing, and consistent hot backups all execute under live traffic.

1. Admin HTTPS API Reference (:9095)

All administrative endpoints (except /healthz) operate strictly over TLS 1.3, require Authorization: Bearer <AdminSecret>, and enforce strict JSON decoding (unknown fields return 400 Bad Request). After 10 failed authentication attempts within 1 minute, the source IP is automatically banned for 5 minutes.

Method & PathAuthPurpose
GET /healthzNoneNode readiness status: 200 {"ok":true} or 503 {"ok":false} when draining or shutting down
GET /metricsBearerNode metrics in Prometheus v0.0.4 text exposition format
GET /v1/admin/statsBearerDetailed JSON telemetry for the node and every local shard (db.NodeStats)
POST /v1/admin/topologyBearerBootstrap or update cluster topology (epoch must strictly increase, else 409 Conflict)
POST /v1/admin/secretsBearerHot-rotate secrets without restarting or dropping active client sessions
POST /v1/admin/drainBearerToggle draining mode and step down Multi-Raft leaders
POST /v1/admin/backupBearerCreate an instant hot snapshot in the target directory
POST /v1/admin/migrateBearerRun online migration of a virtual partition between replica groups (ModeCluster)

2. Zero-Downtime Secret Rotation (POST /v1/admin/secrets)

To rotate ClientSecret, ClusterSecret, or AdminSecret without client errors:

  1. Generate the new secret and push it to /v1/admin/secrets while keeping the previous secret in fallback_*_secrets:
Bash
curl -sk -X POST "https://10.0.1.11:9095/v1/admin/secrets" \
  -H "Authorization: Bearer ${OLD_ADMIN_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "client_secret": "new_client_secret_99887766554433221100aabbccdd",
    "fallback_client_secrets": ["old_client_secret_11223344556677889900ffeeddcc"]
  }'
  1. Roll out the new secret to client applications (during the transition window, the node verifies both secrets in constant time).
  2. Persist the new secret file on disk (or in .env) for future restarts, then call /v1/admin/secrets with "fallback_client_secrets": [] to revoke the old key.

3. Graceful Node Maintenance (Draining)

Before upgrading binaries or rebooting a host, place the node into draining mode:

Bash
curl -sk -X POST "https://10.0.1.12:9095/v1/admin/drain" \
  -H "Authorization: Bearer ${ADMIN_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"draining": true}'

Activating drain immediately switches /healthz on ports :9110 and :9095 to 503 Service Unavailable for load balancers and invokes StepDownAll() to transfer Multi-Raft leadership to peer nodes without election timeouts. Once in-flight requests finish, send SIGTERM to stop the process cleanly.

4. Online Partition Migration (POST /v1/admin/migrate)

In ModeCluster, any virtual partition partID can be moved to another replica group target_group_id that satisfies the shard alignment invariant (partID & shardMask) == (targetGroupID & shardMask). Send the request to the current leader of the source group:

Bash
curl -sk -X POST "https://10.0.1.11:9095/v1/admin/migrate" \
  -H "Authorization: Bearer ${ADMIN_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{
    "partition_id": 256,
    "target_group_id": 16,
    "target_node_id": 3,
    "new_epoch": 2
  }'

Migration executes in two stages:

  1. Background pre-copy (Stage 1): streams a full PEX2 snapshot into the target group without blocking writes on the source.
  2. Barrier and atomic cutover (Stage 2): briefly pauses writes only for partition 256 (the remaining 4095 partitions stay unaffected), establishes a Raft barrier, transfers the final delta (including counters, cursors, deduplication rings, and active 2PC locks), commits the new TOPOLOGY.bin, and redirects clients seamlessly via ErrPartitionMoved.

5. Hot Backups and Recovery

Hot backups run without pausing reads or writes: active MemTables flush to immutable .sst files, .vlog and .slog/.sidx segments rotate, and files are hard-linked into the destination via os.Link (automatically falling back to streaming copy across mount points) alongside a MANIFEST.sha256 verification file:

Bash
curl -sk -X POST "https://10.0.1.11:9095/v1/admin/backup" \
  -H "Authorization: Bearer ${ADMIN_TOKEN}" \
  -H "Content-Type: application/json" \
  -d '{"dest_dir": "/var/backups/sldb/snap_2026_11_30"}'

(cd /var/backups/sldb/snap_2026_11_30 && sha256sum -c MANIFEST.sha256)
  • Restoring Embedded / Standalone: stop the process, copy the backup directory into --data-dir (using the same --shards and --encryption-key-file), and start the server.
  • Restoring ModeCluster: every backup directory is self-contained with IDENTITY, TOPOLOGY.bin, and exact SysSubRaftApplied state. For full-cluster restore, copy each node's snapshot into its --data-dir and restart. To replace a single lost node while quorum remains intact, no backup is required—boot a clean node with the same --node-id and post the current /v1/admin/topology so the leader catches it up via InstallSnapshot.

6. Recovering from Disk Full (ErrDiskFull)

When free space drops below DiskFreeMinBytes or DiskFreeMinPercent:

  1. NodeStats.DiskCircuitOpen turns true, db_disk_full_rejects_total increments, and growth writes (Put, CAS, AddInt64, AppendStream, PatchStream) return db.ErrDiskFull (507 Insufficient Storage on Admin API).
  2. Reads and space-reclaiming operations remain fully operational.
  3. Run Delete, DeleteRange, DeletePrefix, DropNamespace, TrimStream, or DeleteStream: background LSM compaction and VLog GC borrow space from reserve.ballast, rewrite live records, delete obsolete segments, and automatically restore reserve.ballast and reopen writes once free disk space recovers—without restarting the node.

7. Key Prometheus Metrics (GET /metrics)

MetricTypeDescription & Alerting Guidance
db_corruption_errors_totalcounterCRC32C checksum or AES-GCM authentication tag errors (critical alert when > 0)
db_disk_full_rejects_totalcounterWrites rejected by the disk free-space circuit breaker
db_disk_free_bytes / db_ballast_bytesgaugeAvailable filesystem bytes and current reserve.ballast size
db_raft_replica_lag_entriesgaugeMaximum follower log lag in entries across local leader groups
db_clock_skew_errors_totalcounterPackets rejected due to NTP clock drift exceeding MaxClockDrift (500ms)
db_auth_failures_totalcounterFailed client, inter-node, or admin authentication attempts
db_tx_commit_1pc_total / ..._2pc_totalcounterTotal committed single-partition (1PC) and cross-partition (2PC) transactions
db_tx_conflict_total / db_tx_zombie_resolved_totalcounterSSI serialization conflicts and automatically cleaned expired 2PC zombie locks
db_watch_lagged_totalcounterSlow Watch subscribers disconnected due to buffer overflow
db_open_iterators / db_active_watchers / db_active_connectionsgaugeOpen Scan iterators, active Watch streams, and live network connections
db_cache_hit_ratiogaugeBlockCache hit ratio in 0.0 .. 1.0
db_lsm_level_bytes{level="L0".."L4"}gaugeTotal .sst bytes stored per LSM level
db_lsm_tombstone_densitygaugePeak tombstone ratio across active .sst files driving priority compaction
db_kv_latency_microsecondshistogramKV operation latency histogram in microseconds (1 us .. 10 s)
db_stream_latency_microsecondshistogramStream operation latency histogram in microseconds
db_tx_latency_microsecondshistogramTransaction commit latency histogram in microseconds
db_fsync_latency_microsecondshistogramPhysical fdatasync / F_FULLFSYNC latency histogram

8. Complete Error Catalog (errors.Is)

All errors returned by the Go SDK preserve exact server error codes and match standard errors.Is(err, db.Err...) checks:

Error ConstantCodeCause and Recommended Action
ErrNotFound1KV key, stream, or Seq does not exist or has expired via TTL
ErrCASConflict2expectedVer in CAS did not match current version—inspect currentEntry and retry
ErrTxConflict3SSI serialization conflict or live 2PC lock—retry Update with brief backoff
ErrEmptyKey4Empty Key or StreamKey provided
ErrKeyTooLarge5Exceeded length limit for Key (8 KiB), PartKey/StreamKey (512 B), or ConsumerGroup (256 B)
ErrValueTooLarge6Value exceeds MaxValueSize (or stream Header > 64 KiB)
ErrBatchTooLarge7Exceeded 10,000 ops or 16 MiB per batch/transaction
ErrReservedNamespace8Attempted user access to reserved system namespace 0xFFFF (65535)
ErrInvalidRange9Invalid scan or delete range bounds (StartKey >= EndKey)
ErrIncompatibleValueType10AddInt64 invoked on a live non-integer key created via Put
ErrIntegerOverflow11Signed int64 overflow in AddInt64
ErrStreamSeqOutOfRange12PatchStream or RedactStream called for Seq == 0 or Seq > HeadSeq
ErrStreamTrimmed13Requested Seq < FirstSeq has already been removed by TrimStream
ErrSnapshotExpired14View transaction or Scan iterator held longer than MaxSnapshotLifetime (5m)
ErrTooManyPartitions15Transaction touched > 32 partitions or attempted cross-partition stream/DeleteRange in cluster mode
ErrWatchLagged16Watch subscriber buffer overflowed—resync via Scan and reopen watch from new version
ErrOverloaded17TLS handshake semaphore saturated or connection retries exhausted—apply backoff
ErrDiskFull18Disk free-space circuit breaker tripped—reclaim space or expand the volume
ErrClockSkew19Clock drift exceeded MaxClockDrift (500ms)—verify NTP daemon (chrony)
ErrCorruption20On-disk CRC32C checksum mismatch or AES-GCM decryption failure
ErrClosed21Operation attempted on a closed client, iterator, or stopped node
ErrNotLeader / ErrPartitionMoved22 / 23Handled automatically by db.Client; surfaced only if no leader is elected within retries
ErrUncertainCommit24Socket dropped after sending a single non-idempotent call—verify key state or use Update
ErrUnauthorized / ErrIPForbidden25 / 26Invalid client/admin/cluster secret or source IP rejected by IPAllowlist
ErrInvalidTopology / ErrStaleTopologyEpoch27 / 28Shard alignment violated or stale epoch sent to /topology or /migrate
ErrDraining29Target node is draining for maintenance
ErrInvalidConfig / ErrInvalidArgument30 / 31Invalid configuration parameters or call arguments