Skip to content

Add runtime management of eligible server options via CONFIG GET/SET#1965

Draft
vazois wants to merge 2 commits into
mainfrom
vazois/runtime-config
Draft

Add runtime management of eligible server options via CONFIG GET/SET#1965
vazois wants to merge 2 commits into
mainfrom
vazois/runtime-config

Conversation

@vazois

@vazois vazois commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Adds runtime management of eligible GarnetServerOptions through the RESP CONFIG GET / CONFIG SET commands. These options can be viewed and adjusted at runtime because they are read live at their point of use and require no physical change to the running server (no restart, no reallocation).

How

  • ServerConfigType (libs/server/ServerConfigType.cs) is now a public enum augmented with a member per runtime-adjustable option, plus a COUNT sentinel. Time-based members carry an explicit unit suffix (_MS / _SECONDS / _MICROS) matching the underlying GarnetServerOptions property so the unit is unambiguous at every use site.
  • RuntimeServerConfig (libs/server/RuntimeServerConfig.cs, new public class) is a long[]-backed table indexed by ServerConfigType. It is allocation-free, contiguous, O(1) indexed, and read/written with Volatile (atomic on 64-bit). Each slot is a raw 8-byte cell whose interpretation (int / long / bool / enum / seconds-based timeout / string) is described by per-option metadata (ConfigKind). Values are seeded from GarnetServerOptions at startup (Init) and mutated at runtime via TrySet (with per-option range/type validation).
  • The table is held on StoreWrapper.runtimeConfig so the live value is reachable across both the server and cluster layers. GarnetServerOptions remains on StoreWrapper for options that are not runtime-adjustable.
  • ServerConfig.cs: CONFIG GET/CONFIG SET resolve parameter names (honoring aliases, e.g. cluster-timeoutcluster-node-timeout) via RuntimeServerConfig.TryGetType and read/write the table.
  • Read-only params (timeout, save, appendonly, databases) are exposed through CONFIG GET / GET * but reject CONFIG SET with a clear "read-only" error; their values are computed from live server state.
  • slave-read-only stays per-session, following Redis READWRITE/READONLY semantics, and is resolved by the CONFIG GET handler which has the session in scope.
  • Migrated the live read sites across libs/server and libs/cluster to read from the table.

Runtime-adjustable options included

cluster-node-timeout, replica-sync-delay, replica-offset-max-lag, aof-tail-witness-freq, aof-replay-max-drift, repl-diskless-sync-delay, repl-attach-timeout, cluster-replication-reestablishment-timeout, compaction-max-segments, compaction-force-delete, compaction-type, slowlog-log-slower-than, object-scan-count-limit, sg-get.

Tests

  • New tests in test/standalone/Garnet.test/RespConfigTests.cs:
    • ConfigGetSetRuntimeOptionsTest — round-trips integer, long, boolean, enum, seconds-timeout, alias, and multi-option forms.
    • ConfigSetRuntimeOptionValidationTest — rejects malformed / out-of-range values without mutating state.
    • ConfigGetAllAndReadOnlyRejectionTest — read-only params reject SET; GET * includes read-only + per-session slave-read-only.
  • Existing RespAdminCommandsTests.SimpleConfigGet continues to pass (timeout/save/appendonly/slave-read-only/databases/cluster-node-timeout).
  • Server, cluster, and test projects build clean (0 warnings, TreatWarningsAsErrors on); dotnet format --verify-no-changes clean.

Notes

Scope was intentionally limited to "Category A" fully runtime-safe options; not every option is wired up yet. Some previously-considered options (e.g. repl-sync-timeout, gossip-delay) were left out because they are captured at startup and would require additional plumbing.

Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Copilot-Session: 16393bf0-b771-4b90-a5f5-49cc389cd3fc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant