You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: agentStateStore does not support Redis Cluster. #2579
Same area, one more cluster-related point: RedisAgentStateStore.listSessionIds enumerates sessions with JedisClientAdapter.findKeysByPattern, a SCAN loop on a single cursor. On a native Redis Cluster a SCAN has no key, so Jedis (checked on 7.4.1: ClusterConnectionProvider.getConnection returns a random primary when the slot is < 0) sends each call to a random primary, so the result is incomplete and the cursor can be mixed up across nodes. We use listSessionIds to enumerate a user's sessions for deletion; our deployment is a proxy-mode cluster, where it works. If native cluster support is added to the state store, the session enumeration needs to scan every primary or use an index key.
Closing as fixed by #3129 (merged): agent state Redis keys no longer require the same hashslot, enabling Redis Cluster deployments. Reopen if cluster mode still fails.
Activity
[-][Bug]:[/-][+][Bug]: agentStateStore does not support Redis Cluster.[/+]amyaxy commentedon Aug 6, 2026
Redis Cluster CROSSSLOT 错误修复方案
问题
Redis Cluster 模式下,多 key 的 Lua 脚本 (
EVAL) 要求所有 key 哈希到同一 slot,否则抛出:根因
两个组件的多 key Lua 脚本违反了同 slot 约束:
RedisStorePUT_SCRIPT/PUT_IF_VERSION_SCRIPT/DELETE_SCRIPTitem:前缀) + idxKey (idx:前缀)RedisAgentStateStoreSAVE_SCRIPT修复方案:Redis Hash Tag
{...}Redis Cluster 仅根据 key 中
{...}内的子串计算 slot。将相关 key 的公共部分用{}包裹,确保哈希到同一 slot。修改清单(共 4 处,分布在 2 个文件)
文件 1 —
RedisAgentStateStore.java1.
slotId()— 核心修改返回值加
{},所有派生 key(payloadKey、versionKey、keysKey、listKey、hashKey)自动继承同一 hash tag,getStateKey/getListKey/getKeysKey无需改动。效果:以
saveVersioned为例,三个 key 共享 hash tag{user/session}→ 同一 slot:2.
listSessionIds()— 适配新 key 格式更新 SCAN pattern 和解析逻辑以匹配
{prefix}{{user}/{sessionId}}:_keys格式:3.
clearAllSessions()— 改为逐个删除 key避免跨 session 多 key
DEL触发 CROSSSLOT:文件 2 —
RedisStore.java4.
itemKey()/indexKey()— 独立组件hash tag 基于 namespace(与
slotId无关):未修改的组件(无需修改)
RedisSandboxExecutionGuard—RELEASE_SCRIPT只用 1 个 key,无 CROSSSLOT 风险。RedisRemoteSnapshotClient— 不使用 Lua 脚本。RedissonClientAdapter/JedisClientAdapter/LettuceClientAdapter— 适配层,不构造 key。验证
{}仅作为 key 名的一部分,不影响功能。注意事项
"Failed to delete session: {user/session}"),仅展示层小瑕疵,不影响功能。amyaxy commentedon Aug 6, 2026
最初也想过
先判断Redis是否是集群模式
如果是再增加Hash Tag {...},否则保持原样,
后面想了想,复杂度高(Jedis, Lettuce, Redisson都要考虑),也完全没有必要。
fix(redis): add Redis Cluster support for AgentStateStore
fix(redis): add Redis Cluster support for AgentStateStore
fix(redis): add Redis Cluster support for AgentStateStore
fix(redis): add Redis Cluster support for AgentStateStore
xuchaoguo1983 commentedon Oct 2, 2026
Same area, one more cluster-related point:
RedisAgentStateStore.listSessionIdsenumerates sessions withJedisClientAdapter.findKeysByPattern, aSCANloop on a single cursor. On a native Redis Cluster aSCANhas no key, so Jedis (checked on 7.4.1:ClusterConnectionProvider.getConnectionreturns a random primary when the slot is < 0) sends each call to a random primary, so the result is incomplete and the cursor can be mixed up across nodes. We uselistSessionIdsto enumerate a user's sessions for deletion; our deployment is a proxy-mode cluster, where it works. If native cluster support is added to the state store, the session enumeration needs to scan every primary or use an index key.fix(redis): add Redis Cluster support for AgentStateStore
fix(redis): add Redis Cluster support for AgentStateStore
fix(redis): add Redis Cluster support for AgentStateStore
juruoO-o commentedon Nov 12, 2026
Closing as fixed by #3129 (merged): agent state Redis keys no longer require the same hashslot, enabling Redis Cluster deployments. Reopen if cluster mode still fails.