Skip to content

config: warn when redis db is set with cluster_addresses - #4966

Open
sloemo01 wants to merge 1 commit into
livekit:masterfrom
sloemo01:fix/redis-cluster-db-warning
Open

sloemo01 wants to merge 1 commit into
livekit:masterfrom
sloemo01:fix/redis-cluster-db-warning

Conversation

@sloemo01

@sloemo01 sloemo01 commented Oct 8, 2026

Copy link
Copy Markdown

Summary

Adds a startup warning for redis.db set alongside redis.cluster_addresses, where it cannot take effect.

Redis Cluster serves only database 0 and rejects SELECT, and go-redis builds cluster clients without a DB field, so the value is dropped and the server connects to database 0. Users in #2129 moved from single-node Redis to a cluster and assumed the setting carried over; nothing told them it could not.

What I checked while looking at that report: the parse error from the 1.2.4 upgrade (field cluster_addresses not found in type config.RedisConfig) came from that tag not having the field yet, so it is unrelated to the current code. On master, cluster mode works: with a real 3-node Redis Cluster (no auth), a room created through one server instance lists and deletes through the other, and pub/sub over the cluster works. The gap left was the dropped db value, which this change surfaces:

WARN  redis configuration would be ignored  {"reason": "redis.db is set to 3 together with redis.cluster_addresses, but Redis Cluster only supports database 0; the setting is ignored"}

A warning instead of a startup error keeps deployments with a leftover db value starting after an upgrade; they were already running against database 0.

Changes

  • pkg/config/config.go: RedisConfigWarning() reports the conflict.
  • cmd/server/main.go: emits the warning from getConfig, after InitLoggerFromConfig. Output from inside NewConfig is discarded, since the package logger is not initialized until then.
  • config-sample.yaml: documents the restriction in the cluster block.
  • pkg/config/config_test.go: TestRedisConfigWarning covers single-node with db (no warning), cluster with db 0 (no warning), and cluster with a non-zero db (warns).

Testing

  • go build ./cmd/... ./pkg/... clean; go test ./pkg/config/ passes.
  • Live check: a server configured with cluster_addresses and db: 3 logs the warning at startup.
  • Sabotage check: disabling the condition makes TestRedisConfigWarning/cluster_with_non-zero_db fail; the restored file hash matches.

Refs #2129

Redis Cluster serves only database 0 and rejects SELECT, and go-redis
builds cluster clients without a DB field, so redis.db alongside
cluster_addresses is silently ignored: the server uses database 0 with
no diagnostic.

Cluster mode otherwise works on master; this came up while reproducing
the setup confusion in livekit#2129. The warning is emitted from getConfig
after InitLoggerFromConfig, since log output from inside NewConfig is
discarded (the package logger is a no-op until then).

A warning rather than a startup error keeps existing deployments with a
leftover db value starting on upgrade. config-sample.yaml documents
the restriction.

Refs livekit#2129
@sloemo01
sloemo01 requested a review from a team as a code owner October 8, 2026 13:50

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

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