Release lock when deleting cache key #23624
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
I'm seeing
SqlGroup: Failed to acquire lock on cache key.
intermittently on a number of sites. I'm not able to trace the reason because it might happen once a day or less and the cause of the error is always the previous request - ie. the current request cannot get a lock because the previous request didn't release it.Before
if
CRM_Utils_Cache_SqlGroup::set()
called with ttl<=0 cache key is deleted but lock is never released.After
if
CRM_Utils_Cache_SqlGroup::set()
called with ttl<=0 cache key is deleted and lock is released.Technical Details
You can see by tracing the function
delete()
that it performs various actions before returning but does not release the lock. The lock is only released at the bottom of theset()
function but the code returns immediately after the call to delete and never reaches the lock release code.Comments