From 086fdb8257855b563c4b673554b2c0a048ff1f1d Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Fri, 25 Sep 2026 00:04:54 +1000 Subject: [PATCH] fix(session): parse the owner key without assuming the pod id --- .../Session/RedisSessionDirectory.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Emby.Server.Implementations/Session/RedisSessionDirectory.cs b/Emby.Server.Implementations/Session/RedisSessionDirectory.cs index 14be5e0162..e31d1ddb9a 100644 --- a/Emby.Server.Implementations/Session/RedisSessionDirectory.cs +++ b/Emby.Server.Implementations/Session/RedisSessionDirectory.cs @@ -25,7 +25,7 @@ public sealed class RedisSessionDirectory : ISessionDirectory private const string OwnerKeyPrefix = "jellyfin:sessionowner:"; /// - /// Lua script for an atomic ownership claim. The owner key holds pod|connectedTicks, where + /// Lua script for an atomic ownership claim. The owner key holds connectedTicks|pod, where /// the ticks are zero for an instance that holds no connection. A claim by another instance is /// refused unless its connection is newer than the recorded one, so the instance holding the live /// connection keeps ownership however many requests the others serve. @@ -34,13 +34,13 @@ public sealed class RedisSessionDirectory : ISessionDirectory local current = redis.call('GET', KEYS[1]) if current then local separator = string.find(current, '|', 1, true) - local owner = string.sub(current, 1, separator - 1) - local connected = tonumber(string.sub(current, separator + 1)) + local connected = tonumber(string.sub(current, 1, separator - 1)) + local owner = string.sub(current, separator + 1) if owner ~= ARGV[1] and connected > 0 and tonumber(ARGV[2]) <= connected then return 0 end end -redis.call('SET', KEYS[1], ARGV[1] .. '|' .. ARGV[2], 'PX', ARGV[4]) +redis.call('SET', KEYS[1], ARGV[2] .. '|' .. ARGV[1], 'PX', ARGV[4]) redis.call('SET', KEYS[2], ARGV[3], 'PX', ARGV[4]) return 1"; @@ -52,7 +52,7 @@ return 1"; local current = redis.call('GET', KEYS[1]) if not current then return 0 end local separator = string.find(current, '|', 1, true) -if string.sub(current, 1, separator - 1) ~= ARGV[1] then return 0 end +if string.sub(current, separator + 1) ~= ARGV[1] then return 0 end redis.call('DEL', KEYS[1], KEYS[2]) return 1";