feat: Add Redis Sentinel support for HA#6125
Open
timon0305 wants to merge 4 commits intoreflex-dev:mainfrom
Open
feat: Add Redis Sentinel support for HA#6125timon0305 wants to merge 4 commits intoreflex-dev:mainfrom
timon0305 wants to merge 4 commits intoreflex-dev:mainfrom
Conversation
Contributor
Greptile OverviewGreptile SummaryThis PR adds Redis Sentinel support for high availability deployments by introducing 5 new configuration fields ( Key changes:
Issues found:
Confidence Score: 3/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant App as Application
participant SM as StateManager
participant Prereq as prerequisites
participant Sentinel as Redis Sentinel
participant Master as Redis Master
App->>SM: StateManager.create()
SM->>Prereq: _get_sentinel_config()
Prereq->>Prereq: Check config.redis_sentinel_nodes
Prereq-->>SM: Returns sentinel config or None
alt Sentinel configured
SM->>SM: Set state_manager_mode to REDIS
SM->>Prereq: get_redis()
Prereq->>Prereq: _get_sentinel_config()
Prereq->>Prereq: _parse_sentinel_nodes()
Prereq->>Sentinel: Create Sentinel(nodes, password)
Sentinel-->>Prereq: Sentinel instance
Prereq->>Sentinel: master_for(service, db, password, ssl)
Sentinel->>Master: Discover master
Master-->>Sentinel: Master connection
Sentinel-->>Prereq: Redis client
Prereq-->>SM: Redis client
SM->>SM: Create StateManagerRedis
else redis_url configured
SM->>Prereq: get_redis()
Prereq->>Prereq: parse_redis_url()
Prereq->>Master: Redis.from_url()
Master-->>Prereq: Redis client
Prereq-->>SM: Redis client
end
|
masenf
reviewed
Feb 12, 2026
Collaborator
masenf
left a comment
There was a problem hiding this comment.
the StateManagerRedis is created and bound to the redis instance when the app starts. What is the mechanism for failing over to a different redis instance while the server is running? Seems like we might need some checking in an error path for when the redis connection is unavailable and then request the next master from the sentinal nodes
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.
Summary
Closes #5830
BaseConfig(redis_sentinel_nodes,redis_sentinel_service,redis_sentinel_password,redis_sentinel_db,redis_sentinel_ssl)get_redis()andget_redis_sync()to create Sentinel-backed clients when configured, using redis-py's built-inSentinelclassStateManager.create()to auto-detect Redis mode when Sentinel config is presentredis_urlorredis_sentinel_nodes+redis_sentinel_serviceUsage
In
rxconfig.py:Or via environment variables:
Files changed (3)
reflex/config.py- Added 5 sentinel config fields, updated validation, added password to sensitive env varsreflex/utils/prerequisites.py- Added_parse_sentinel_nodes(),_get_sentinel_config(), updatedget_redis()andget_redis_sync()with sentinel pathreflex/istate/manager/__init__.py- UpdatedStateManager.create()auto-detection to include sentinel configNotes
None, existingredis_urlbehavior unchangedredis_urlwhen both are configuredREFLEX_*env var overrides automaticallyTest plan