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
I experience deadlocks when having a lot of parallel requests.
With set $session_redis_pool_size 1 I can reproduce it always with just two requests.
The code is basically:
session:open()
dosomething()
session:close()
With some debug logs I think I figured out the reason.
request 1 opens/locks session
request 1 "open" puts connect back to pool ("set_keepalive")
requests 1 does something
requests 2 comes in and opens connection to redis pool. session is locked so it trys to aquire lock which takes time to time out
request 1 did something and wants to close session. session:close cannot get a connection to unlock because requests 2 blocks the session waiting for the lock
Is there a good way to prevent this?
I am using lua resty session 3.
With a bigger pool size there are factors which makes the deadlock more or less likely. It looks like http2 is a factor since there can be more parallel client connections.
The text was updated successfully, but these errors were encountered:
I found a possible solution, but it requires code change in storage/redis.lua at function storage.lock(key)
-- put connection back to pool
self:set_keepalive()
sleep(waittime)
-- reconnect
local ok, err = self:connect()
if not ok then
return nil, err
end
This puts the connection during spin lock wait back to the connection pool. This might introduce some overhead during waiting for a lock but it eliminates the deadlocks.
I experience deadlocks when having a lot of parallel requests.
With
set $session_redis_pool_size 1
I can reproduce it always with just two requests.The code is basically:
With some debug logs I think I figured out the reason.
Is there a good way to prevent this?
I am using lua resty session 3.
With a bigger pool size there are factors which makes the deadlock more or less likely. It looks like http2 is a factor since there can be more parallel client connections.
The text was updated successfully, but these errors were encountered: