bug: GetOrSet deadlock
Closed this issue · 2 comments
vlasashk commented
Mutex is not released in case of expired entry in func GetOrSet()
c.mu.Unlock() should be added
if ok {
c.m[key] = c.queue.add(entry[K, V]{key: key, val: val, exp: exp.new(now, c.defaultExp, c.sliding)})
c.queue.remove(currentNode)
c.mu.Unlock()
if c.onEviction != nil {
go c.onEviction(key, currentNode.entry().val, EvictionReasonExpired)
}
return val, false
}
erni27 commented
Hi. Thanks for submitting the issue. This indeed should be fixed.
To avoid similar issues I feel like the implementation should rely on 'differ' statement instead (especially given the Go team effort to make it efficient). The current way of mutex handling is rather an artifact of the old implementation when using 'differ' wasn't convenient.
I'll try to fix it this week unless you want to do it.