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 15 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? |
kevin-montrose
left a comment
There was a problem hiding this comment.
Couple nits, and some potential bugs.
What
Introduces a runtime configuration management registry for RESP
CONFIG GETandCONFIG SET.Design
Configuration parameters are explicitly registered as either:
CONFIG GETfor informational purposes and are formatted from the retainedGarnetServerOptions.Runtime values are managed by a shared
RuntimeServerConfiginstance. Numeric values, booleans, enums, and durations are stored in numeric slots, while read-only parameters may also use string formatters.RuntimeServerConfigprovides typed accessors—includingGetInt,GetLong,GetBool,GetEnum<T>,GetTimeSpan, and duration-unit conversions—so callers can consume each value in the form they require.For settings associated with independently restartable background tasks,
ConfigMeta.UpdateActionapplies the change by reconciling the affected task without restarting the server. This PR includes examples for AOF commit frequency, expired-object collection, and expired-key deletion scanning, but does not attempt to cover every parameter that could support this behavior.Adding parameters to the configuration management registry is intentionally opt-in. A parameter must be registered with metadata and, for read-write settings, its consumers must read from
RuntimeServerConfig. This PR adds a representative set of read-only and read-write parameters to demonstrate the feature and establish the extension pattern.Additional behavior
CONFIG SETvalidates types, ranges, and enum members before publishing a value.CONFIG GET *includes registered read-only and read-write parameters.slave-read-onlyremain outside the shared registry.Tests
Tests cover runtime GET/SET operations, supported value types, aliases, validation, read-only rejection,
CONFIG GET *, live slowlog updates, and background-task configuration changes.