SKEG · OPERATE

Operating Skeg

Operate the store and understand its resource and shutdown boundaries.

Skeg 0.8 · Development documentation

Watch memory headroom, storage space and maintenance failures while the server runs. When stopping it, allow time for accepted work to finish and for files to be synchronised. This page covers those day-to-day tasks; use deployment for network and storage setup.

Check startup and recovery

Check the startup log for the bound address and shard count. On a local RESP listener, run these commands from an interactive client. Sign in first if the server requires authentication.

PING
GET document:42
SKEG.VINDEX.INFO documents

PONG confirms that the listener responds. Compare the other replies with a known application key and index, using the tenant and protocol the application will use. Substitute your own key and index names.

Before the listener opens, Skeg must recover each shard. When a shard has no usable snapshot, it can scan its value log. With a tight recovery budget, Skeg can scan the log in multiple passes. After a successful full scan, the shard logs log recovered by a full scan: no usable snapshot with the number of passes, bytes scanned and elapsed time. Use those fields to diagnose a slow start. If startup exits instead, read the first shard-open error.

If startup reports that an explicit memory.ingress_budget_bytes exceeds available memory, check the configured reserve and actual headroom. Lower the fixed budget or use memory.ingress_fraction to derive it from headroom. See memory profiles and ingress.

Memory and maintenance

On Linux the admission governor reads available headroom across the process’s cgroup v2 hierarchy. It retains a margin before admitting request buffers, vector growth and maintenance working sets. If headroom is known at startup, the default retained margin is max(64 MiB, initial effective headroom/10); otherwise it is 64 MiB. Set memory.reserve_bytes to a positive byte count to override that margin. See configuration.

SKEG_MEMORY_LIMIT_BYTES sets a ceiling on admission headroom. It can tighten a known cgroup reading, but it is not a total process RSS limit and does not subtract existing RSS from the configured value. On a platform without a finite cgroup reading, the governor is unlimited unless an explicit ceiling is configured. Use OS/container controls for the process envelope and monitor actual memory consumption separately.

Read skeg_memory_budget_state before interpreting skeg_memory_headroom_bytes: the headroom series is absent when the budget is unlimited or unknown. skeg_memory_reserved_bytes reports outstanding promises; it is different from the retained margin, skeg_memory_reserve_bytes. See memory signals.

Maintenance estimates its working set before starting. Graph-heavy work also needs a concurrency permit. Distinguish the resulting signals:

ObservationFirst action
Automatic maintenance is deferredCheck headroom and whether backlog continues to grow; deferral alone is not a failed job.
Explicit consolidation returns BACKPRESSUREDefer it with a bounded retry policy rather than repeatedly forcing the same work.
Maintenance-failure counters increaseInspect the associated logs and storage state.
Cleanup failures increase after a committed jobInspect leftover files and free space; the committed job is not automatically rolled back.

Use SKEG.HEALTH <index> and SKEG.VINDEX.SHARDS <index> for per-index and per-shard maintenance state. Check which shard reports a growing backlog before changing a process-wide setting. See inspect one index for how to read the replies.

Re-rank row cache: memory versus latency

memory.query_cache_bytes sets a shared budget for the re-rank row caches across the process. The default depends on the memory profile. Zero disables row caching. The SKEG_RERANK_CACHE_MB alias sets the same shared budget in MiB.

To compare performance with caching disabled, set this in your configuration file before restarting:

memory:
  query_cache_bytes: 0

Use skeg config show --config skeg.yaml --sources memory.query_cache_bytes to confirm the budget and check for overrides.

Compare the same queries and explicit search effort, with warm-up separated from measurement. Track memory, open segments and latency alongside skeg_rerank_cache_hits_total and skeg_rerank_cache_misses_total. The miss counter does not count uncached reads when this cache is disabled. Cache reuse is not itself a latency result, and cache tuning does not replace recall measurement when changing search effort.

Graceful shutdown

Use the supervisor’s normal stop command, SIGTERM or Ctrl+C. The server closes its listener, drains accepted connections, finishes accepted shard work, joins background maintenance and synchronises persistent vector WALs and shard VLogs before reporting its final status.

The connection-drain deadline is SKEG_SHUTDOWN_TIMEOUT_MS (default 30000). Expired connection tasks are aborted and the shutdown records a failure; remaining shard barriers are still attempted. The deadline does not bound disk I/O or total shutdown time.

For a planned stop:

  1. Pause application writes and import jobs.
  2. Stop the service and allow it to finish. For a systemd unit named skeg.service, use systemctl stop skeg.service.
  3. Check the final exit status and logs before copying files or treating the stop as clean.

Exit zero means the shutdown barriers reported success. A timeout, task panic or synchronisation error produces a nonzero result. A forced SIGKILL cannot run the shutdown sequence. For the different meanings of operation replies, read write outcomes.

The counters are skeg_shutdown_started_total, skeg_shutdown_completed_total, skeg_shutdown_failures_total, and skeg_shutdown_connection_timeouts_total. Because a successful shutdown ends the process immediately after incrementing them, retain the final scrape or use the supervisor’s exit status and logs as the authoritative outcome.

Docker and Compose

The image declares STOPSIGNAL SIGTERM. Allow longer than the internal connection deadline for maintenance already in flight and filesystem syncs:

docker stop --time 120 skeg

The supplied Compose example sets stop_grace_period: 2m. These example allowances must be checked against your store’s observed stop time. Do not set the container runtime’s grace period equal to SKEG_SHUTDOWN_TIMEOUT_MS; that would leave no time for the shard barriers after connection draining.

systemd

Use an ordinary foreground service and let systemd observe the exit code:

[Service]
ExecStart=/usr/local/bin/skeg --data-dir /var/lib/skeg
Environment=SKEG_SHUTDOWN_TIMEOUT_MS=30000
KillSignal=SIGTERM
TimeoutStopSec=120
Restart=on-failure

An unclean stop should be investigated before an automatic restart loop hides it. In particular, any increase in skeg_vlog_flush_failures_total or a log line containing vector WAL sync means the last durability barrier failed.

Watch disk space

Tenant disk quotas count logical live records and payloads, not all physical files. Leave room for vector data, graphs, WALs, obsolete records and temporary maintenance files. Deletion does not immediately shrink the store directory.

Inspect the filesystem holding the data path, for example:

df -h /var/lib/skeg
du -sh /var/lib/skeg

df reports filesystem capacity and free space; du walks the named directory and reports its allocated usage. They measure different things. A directory walk can be expensive on a large store, so do not put it on every request or high-frequency liveness check. Monitor the volume’s free space separately from logical quota usage.

Keep auth files and any external paths in the operating inventory too. A full filesystem can prevent writes, maintenance or clean shutdown. Investigate an ENOSPC error before resuming a failed import; replaying requests does not create space.

Back up the store

Stop the server successfully before copying its files, and keep the data root, authentication store and quota sidecar from the same stopped state. Follow backup and restore for the procedure.