Skip to content

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

Open
vazois wants to merge 15 commits into
mainfrom
vazois/runtime-config
Open

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

Conversation

@vazois

@vazois vazois commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

What

Introduces a runtime configuration management registry for RESP CONFIG GET and CONFIG SET.

Design

Configuration parameters are explicitly registered as either:

  • Read-only: Startup or physical settings that cannot be changed without restarting the server. They are exposed through CONFIG GET for informational purposes and are formatted from the retained GarnetServerOptions.
  • Read-write: Settings that can change without restarting the server. Changes either take effect through live reads or may require restarting a related background task.

Runtime values are managed by a shared RuntimeServerConfig instance. Numeric values, booleans, enums, and durations are stored in numeric slots, while read-only parameters may also use string formatters.

RuntimeServerConfig provides typed accessors—including GetInt, 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.UpdateAction applies 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

  • Parameter names are resolved case-insensitively and may define aliases.
  • CONFIG SET validates types, ranges, and enum members before publishing a value.
  • Failed update actions restore the previous value.
  • CONFIG GET * includes registered read-only and read-write parameters.
  • Session-specific settings such as slave-read-only remain 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.

@vazois
vazois marked this pull request as ready for review July 23, 2026 18:43
Copilot AI review requested due to automatic review settings July 23, 2026 18:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 expands ServerConfigType to cover runtime-adjustable and read-only CONFIG parameters.
  • Updates CONFIG GET/SET handling to resolve parameters via RuntimeServerConfig (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 thread libs/server/ServerConfig.cs
Comment thread libs/server/RuntimeServerConfig.cs Outdated
Comment thread libs/server/Resp/RespServerSession.cs Outdated
@Mathos1432

Copy link
Copy Markdown
Contributor

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?

Comment thread libs/server/RuntimeServerConfig.cs Outdated
Comment thread libs/server/RuntimeServerConfig.cs Outdated

@kevin-montrose kevin-montrose left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple nits, and some potential bugs.

Comment thread libs/server/RuntimeServerConfig.cs Outdated
Comment thread libs/server/RuntimeServerConfig.cs Outdated
Comment thread libs/server/RuntimeServerConfig.cs Outdated
Comment thread libs/server/RuntimeServerConfig.cs Outdated
Comment thread libs/server/ServerConfigType.cs Outdated
Comment thread libs/server/StoreWrapper.cs Outdated
Comment thread test/standalone/Garnet.test/RespConfigTests.cs Outdated
Comment thread test/standalone/Garnet.test/RespConfigTests.cs Outdated
@vazois
vazois marked this pull request as draft August 3, 2026 17:21
@vazois
vazois marked this pull request as ready for review August 4, 2026 18:05
@kevin-montrose
kevin-montrose self-requested a review August 4, 2026 18:29
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.

5 participants