Add runtime management of eligible server options via CONFIG GET/SET#1965
Open
vazois wants to merge 3 commits into
Open
Add runtime management of eligible server options via CONFIG GET/SET#1965vazois wants to merge 3 commits into
vazois wants to merge 3 commits into
Conversation
vazois
marked this pull request as ready for review
July 23, 2026 18:43
Contributor
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. |
Comment on lines
+40
to
44
| // Extract requested parameters. All CONFIG parameters (settable and read-only) are served | ||
| // through the runtime config table. | ||
| List<ServerConfigType> parameters = null; | ||
| var returnAll = false; | ||
| for (var i = 0; i < parseState.Count; i++) |
Comment on lines
+235
to
+242
| case ConfigKind.Seconds: | ||
| { | ||
| if (!int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var seconds)) | ||
| return $"ERR Invalid value for '{meta.Name}': expected an integer number of seconds."; | ||
| // <= 0 is stored as-is and interpreted as an infinite timeout on read. | ||
| Volatile.Write(ref values[(int)type], seconds); | ||
| return null; | ||
| } |
Comment on lines
+316
to
+318
| var slowLogThresholdConfig = storeWrapper.runtimeConfig.GetInt(ServerConfigType.SLOWLOG_LOG_SLOWER_THAN_MICROS); | ||
| if (slowLogThresholdConfig > 0) | ||
| slowLogThreshold = (long)(slowLogThresholdConfig * OutputScalingFactor.TimeStampToMicroseconds); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.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