fix(session): parse the owner key without assuming the pod id
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful

This commit is contained in:
2026-09-25 00:04:54 +10:00
parent 51261b0128
commit 086fdb8257
@@ -25,7 +25,7 @@ public sealed class RedisSessionDirectory : ISessionDirectory
private const string OwnerKeyPrefix = "jellyfin:sessionowner:";
/// <summary>
/// Lua script for an atomic ownership claim. The owner key holds <c>pod|connectedTicks</c>, where
/// Lua script for an atomic ownership claim. The owner key holds <c>connectedTicks|pod</c>, 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";