beta9 icon indicating copy to clipboard operation
beta9 copied to clipboard

Remove an unnecessary lock inside the RedisLock data struct

Open jsun-m opened this issue 1 year ago • 0 comments

This lock was initially meant to protect the in memory lock dictionary that was removed. Since this redis lock is usually shared by an entire repository data struct (e.g ContainerRedisRepo), there is a possibility for causing deadlocks when that lock is nested within itself but for different keys.

example

cr.lock.Acquire(context.TODO(), common.RedisKeys.SomeKey...)
     ...
     cr.lock.Acquire(context.TODO(), common.RedisKeys.SchedulerContainerLock(containerId)....)
     cr.lock.Releae(common.RedisKeys.SchedulerContainerLock(containerId))
     ...
cr.lock.Release(context.TODO(), common.RedisKeys.SomeKey...)

jsun-m avatar May 24 '24 20:05 jsun-m