Add runtime management of eligible server options via CONFIG GET/SET - #1965
Add runtime management of eligible server options via CONFIG GET/SET#1965vazois wants to merge 10 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a centralized RuntimeServerConfig table and wires CONFIG GET/CONFIG SET to manage a subset of server options at runtime, with call sites updated across server + cluster layers to read live values.
Changes:
- Introduces
RuntimeServerConfig(long[] + metadata) and expandsServerConfigTypeto cover runtime-adjustable and read-only CONFIG parameters. - Updates
CONFIG GET/SEThandling to resolve parameters viaRuntimeServerConfig(including aliases) and formats responses via canonical names. - Migrates multiple option read sites (object scan, sg-get, compaction, replication timeouts/delays, etc.) to read from the runtime table; adds tests for round-tripping and validation.
Reviewed changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| test/standalone/Garnet.test/RespConfigTests.cs | Adds tests covering runtime CONFIG GET/SET round-trips, validation failures, and GET * contents. |
| libs/server/StoreWrapper.cs | Adds shared runtimeConfig to StoreWrapper and ensures clones share the same table. |
| libs/server/Storage/Session/StorageSession.cs | Plumbs RuntimeServerConfig into StorageSession and removes cached object-scan limit. |
| libs/server/Storage/Session/ObjectStore/Common.cs | Reads object scan count limit from runtimeConfig at use site. |
| libs/server/ServerConfigType.cs | Makes enum public and adds runtime-adjustable options with unit-suffixed members + COUNT sentinel. |
| libs/server/ServerConfig.cs | Routes CONFIG name parsing through RuntimeServerConfig; rewrites CONFIG GET/SET to use runtime table. |
| libs/server/RuntimeServerConfig.cs | New runtime-config table with metadata, parsing/validation, formatting, and alias resolution. |
| libs/server/Resp/RespServerSession.cs | Uses runtime config for slowlog threshold initialization; removes cached sg-get flag. |
| libs/server/Resp/Objects/SharedObjectCommands.cs | Uses runtime config for object scan count limit in RESP object commands. |
| libs/server/Resp/BasicCommands.cs | Uses runtime config for sg-get decision in GET dispatch path. |
| libs/server/Databases/DatabaseManagerBase.cs | Uses runtime config for compaction parameters. |
| libs/cluster/Server/Replication/ReplicationManager.cs | Uses runtime config for replication reestablishment timeout and AOF tail witness delay. |
| libs/cluster/Server/Replication/ReplicaOps/ReplicaDisklessSync.cs | Uses runtime config for replica attach timeout. |
| libs/cluster/Server/Replication/ReplicaOps/ReplicaDiskbasedSync.cs | Uses runtime config for replica attach timeout. |
| libs/cluster/Server/Replication/ReplicaOps/AOFReplay/ReplicaReplaySession.cs | Uses runtime config for replication offset max lag checks / sync replay decision. |
| libs/cluster/Server/Replication/ReplicaOps/AOFReplay/ReplicaReplayDriver.cs | Uses runtime config for replay max drift, sync delay, and max-lag throttling. |
| libs/cluster/Server/Replication/PrimaryOps/DisklessReplication/ReplicationSyncManager.cs | Uses runtime config for diskless sync delay. |
| libs/cluster/Server/Replication/PrimaryOps/AofOperations/AofSyncTask.cs | Uses runtime config for replica sync delay used by AOF sync consumption. |
| libs/cluster/Server/Replication/PrimaryOps/AofOperations/AofSyncDriver.cs | Uses runtime config for AOF tail witness frequency delay. |
| libs/cluster/Server/ClusterProvider.cs | Exposes replication_offset_max_lag from runtime config in replication info metrics. |
|
If the configurations are still present in GarnetServerOptions, is there a risk that some code paths go through the "static" GarnetServerOptions instead of the runtime options, causing some paths to use the updated value and some to use the boot time value? Is it possible to remove the runtime configs from the GarnetServerOptions, or make it hard to accidentally read their values? |
| Int64, | ||
| Bool, | ||
| Enum, | ||
| Seconds, |
There was a problem hiding this comment.
I wonder if it would be possible to instead have TimeSpan as a ConfigKind and use that instead of Seconds/Int32 for encoding/decoding?
It would avoid the need to encode the unit as a suffix which reduces the risk of incorrect storing/retrieval?
There was a problem hiding this comment.
I added the appropriate Getter for this and also a collection of flags to indicate differents it can be retrieved as, i.e. TimeSpan, Int seconds, Int Milliseconds, etc.
kevin-montrose
left a comment
There was a problem hiding this comment.
Couple nits, and some potential bugs.
| this.serverOptions = serverOptions; | ||
| // Share the runtime config table across cloned wrappers (e.g. the AOF copy ctor) so that a | ||
| // CONFIG SET is observed consistently; otherwise seed a fresh table from the startup options. | ||
| this.runtimeConfig = runtimeConfig ?? new RuntimeServerConfig(); |
There was a problem hiding this comment.
Rather than this if, pass this and serverOptions to RuntimeServerConfig constructor.
| var db = redis.GetDatabase(0); | ||
|
|
||
| // Out-of-range integer (min is 0). | ||
| _ = Assert.Throws<RedisServerException>(() => db.Execute("CONFIG", "SET", "replica-sync-delay", "-5")); |
There was a problem hiding this comment.
We should check that the error messages are what we expect.
| var db = redis.GetDatabase(0); | ||
|
|
||
| // CONFIG SET on read-only parameters is rejected. | ||
| _ = Assert.Throws<RedisServerException>(() => db.Execute("CONFIG", "SET", "appendonly", "yes")); |
There was a problem hiding this comment.
Similarly, we should check the error messages are correct.
What
Adds runtime management of eligible
GarnetServerOptionsthrough the RESPCONFIG GET/CONFIG SETcommands. 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 apublicenum augmented with a member per runtime-adjustable option, plus aCOUNTsentinel. Time-based members carry an explicit unit suffix (_MS/_SECONDS/_MICROS) matching the underlyingGarnetServerOptionsproperty so the unit is unambiguous at every use site.RuntimeServerConfig(libs/server/RuntimeServerConfig.cs, newpublicclass) is along[]-backed table indexed byServerConfigType. It is allocation-free, contiguous, O(1) indexed, and read/written withVolatile(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 fromGarnetServerOptionsat startup (Init) and mutated at runtime viaTrySet(with per-option range/type validation).StoreWrapper.runtimeConfigso the live value is reachable across both the server and cluster layers.GarnetServerOptionsremains onStoreWrapperfor options that are not runtime-adjustable.ServerConfig.cs:CONFIG GET/CONFIG SETresolve parameter names (honoring aliases, e.g.cluster-timeout→cluster-node-timeout) viaRuntimeServerConfig.TryGetTypeand read/write the table.timeout,save,appendonly,databases) are exposed throughCONFIG GET/GET *but rejectCONFIG SETwith a clear "read-only" error; their values are computed from live server state.slave-read-onlystays per-session, following RedisREADWRITE/READONLYsemantics, and is resolved by theCONFIG GEThandler which has the session in scope.libs/serverandlibs/clusterto 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
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-sessionslave-read-only.RespAdminCommandsTests.SimpleConfigGetcontinues to pass (timeout/save/appendonly/slave-read-only/databases/cluster-node-timeout).TreatWarningsAsErrorson);dotnet format --verify-no-changesclean.