We have some race condition with the Cache Contracts component that happen in some case.
I dig in the code and found that the Cache component use the LockRegistry to prevent more than 20 computes at the same time and only one compute per item key.
During the compute of one of our cache an other cache is compute with a different cache key, but if both cache are empty (at least at start) the second one cannot acquire the lock because of bad luck the abs(crc32($item->getKey())) % \count(self::$files) return the same value and then the same lock.
My solution to solve this would be:
Having the lock only on the item key and not a mix
Disable the lock per call (but will release all current acquired locks and could have side effect).
Or The PSR6 cache but lose the lock / stampede feature
Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
Directly mention a user or teamReference an issue or pull request
Add heading textAdd bold text, <Ctrl+b>Add italic text, <Ctrl+i>Add a bulleted list, <Ctrl+Shift+8>Add a numbered list, <Ctrl+Shift+7>Add a task list, <Ctrl+Shift+l>
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
You can’t perform that action at this time.
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.
-
Hello,
We have some race condition with the Cache Contracts component that happen in some case.
I dig in the code and found that the Cache component use the
LockRegistry
to prevent more than 20 computes at the same time and only one compute per item key.During the compute of one of our cache an other cache is compute with a different cache key, but if both cache are empty (at least at start) the second one cannot acquire the lock because of bad luck the
abs(crc32($item->getKey())) % \count(self::$files)
return the same value and then the same lock.My solution to solve this would be:
What would you recommend to fix those case ?
Beta Was this translation helpful? Give feedback.