mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 03:36:36 +08:00
fix(redis): Redis Cluster eval errors by adding hash tags to trigger debug keys (#31701)
This commit is contained in:
parent
d6a787497f
commit
95d68437d1
@ -23,8 +23,8 @@ class TriggerDebugEventBus:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
# LUA_SELECT: Atomic poll or register for event
|
# LUA_SELECT: Atomic poll or register for event
|
||||||
# KEYS[1] = trigger_debug_inbox:{tenant_id}:{address_id}
|
# KEYS[1] = trigger_debug_inbox:{<tenant_id>}:<address_id>
|
||||||
# KEYS[2] = trigger_debug_waiting_pool:{tenant_id}:...
|
# KEYS[2] = trigger_debug_waiting_pool:{<tenant_id>}:...
|
||||||
# ARGV[1] = address_id
|
# ARGV[1] = address_id
|
||||||
LUA_SELECT = (
|
LUA_SELECT = (
|
||||||
"local v=redis.call('GET',KEYS[1]);"
|
"local v=redis.call('GET',KEYS[1]);"
|
||||||
@ -35,7 +35,7 @@ class TriggerDebugEventBus:
|
|||||||
)
|
)
|
||||||
|
|
||||||
# LUA_DISPATCH: Dispatch event to all waiting addresses
|
# LUA_DISPATCH: Dispatch event to all waiting addresses
|
||||||
# KEYS[1] = trigger_debug_waiting_pool:{tenant_id}:...
|
# KEYS[1] = trigger_debug_waiting_pool:{<tenant_id>}:...
|
||||||
# ARGV[1] = tenant_id
|
# ARGV[1] = tenant_id
|
||||||
# ARGV[2] = event_json
|
# ARGV[2] = event_json
|
||||||
LUA_DISPATCH = (
|
LUA_DISPATCH = (
|
||||||
@ -43,7 +43,7 @@ class TriggerDebugEventBus:
|
|||||||
"if #a==0 then return 0 end;"
|
"if #a==0 then return 0 end;"
|
||||||
"redis.call('DEL',KEYS[1]);"
|
"redis.call('DEL',KEYS[1]);"
|
||||||
"for i=1,#a do "
|
"for i=1,#a do "
|
||||||
f"redis.call('SET','trigger_debug_inbox:'..ARGV[1]..':'..a[i],ARGV[2],'EX',{TRIGGER_DEBUG_EVENT_TTL});"
|
f"redis.call('SET','trigger_debug_inbox:{{'..ARGV[1]..'}}'..':'..a[i],ARGV[2],'EX',{TRIGGER_DEBUG_EVENT_TTL});"
|
||||||
"end;"
|
"end;"
|
||||||
"return #a"
|
"return #a"
|
||||||
)
|
)
|
||||||
@ -108,7 +108,7 @@ class TriggerDebugEventBus:
|
|||||||
Event object if available, None otherwise
|
Event object if available, None otherwise
|
||||||
"""
|
"""
|
||||||
address_id: str = hashlib.sha256(f"{user_id}|{app_id}|{node_id}".encode()).hexdigest()
|
address_id: str = hashlib.sha256(f"{user_id}|{app_id}|{node_id}".encode()).hexdigest()
|
||||||
address: str = f"trigger_debug_inbox:{tenant_id}:{address_id}"
|
address: str = f"trigger_debug_inbox:{{{tenant_id}}}:{address_id}"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
event_data = redis_client.eval(
|
event_data = redis_client.eval(
|
||||||
|
|||||||
@ -42,7 +42,7 @@ def build_webhook_pool_key(tenant_id: str, app_id: str, node_id: str) -> str:
|
|||||||
app_id: App ID
|
app_id: App ID
|
||||||
node_id: Node ID
|
node_id: Node ID
|
||||||
"""
|
"""
|
||||||
return f"{TriggerDebugPoolKey.WEBHOOK}:{tenant_id}:{app_id}:{node_id}"
|
return f"{TriggerDebugPoolKey.WEBHOOK}:{{{tenant_id}}}:{app_id}:{node_id}"
|
||||||
|
|
||||||
|
|
||||||
class PluginTriggerDebugEvent(BaseDebugEvent):
|
class PluginTriggerDebugEvent(BaseDebugEvent):
|
||||||
@ -64,4 +64,4 @@ def build_plugin_pool_key(tenant_id: str, provider_id: str, subscription_id: str
|
|||||||
provider_id: Provider ID
|
provider_id: Provider ID
|
||||||
subscription_id: Subscription ID
|
subscription_id: Subscription ID
|
||||||
"""
|
"""
|
||||||
return f"{TriggerDebugPoolKey.PLUGIN}:{tenant_id}:{str(provider_id)}:{subscription_id}:{name}"
|
return f"{TriggerDebugPoolKey.PLUGIN}:{{{tenant_id}}}:{str(provider_id)}:{subscription_id}:{name}"
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user