dice
dice copied to clipboard
BUG: Deadlock while cache eviction
Hi team,
This issue was first reported as per conversation on the discord community by Ritik. To replicate the issue, please follow the steps below:
- Update the KeysLimit in dice/config/config.go
var KeysLimit int = 2 // default buffer size.
- Run following commands
mset a b c d
works fineset x y
should lead to deadlock
Upon initial debugging, I found the issue is due to the locks being acquired in functions when trying to set a new value. Please find the sequence leading to deadlock below:
- evalSet calls store.Put()
- store.Put() calls PutHelper with acquiring Lock()
- PutHelper() validates the key limit and goes for eviction via store.evict()
- In populateEvictionPool() we try to get RLock() to evict, which causes deadlock as Lock() is already acquired on step 2.
cc: @JyotinderSingh
Regards, Apoorv