currently, variable_initialize can take down sites when the lock system is failing. Among other things, the use of recursion can cause a PHP segfault under high enough load.
this patch allows a configurable (as in a setting in settings.php) number of tries to get a lock when rebuilding the variable cache.
if a request fails to get a lock after $configurable_attempts, it simply proceeds with the non-cached code path.
Discussed with catch in IRC. while a better approach was at: #973436: Overzealous locking in variable_initialize() we should go ahead with this simpler fix of giving up reading from the DB.
Comments
Comment #1
pwolanin commentedCode style fixes neede: else if -> elseif
Also, need a 2nd param to lock_wait(), since we don't want to wait 30 sec.
Comment #2
pwolanin commentedComment #3
Anonymous (not verified) commentedupdated patch.
Comment #6
pwolanin commentedThis is an important fix - the recursion instead of a loop is a really bad pattern, and allowing this to fail out and read is an important improvement.
Discussion the failure modes, I think a lock lifetime of somethign shorter like 5 sec passed to lock_acquire() might be a good idea, but I think 1 in current core is too small.
An then we should reduce the lock wait time to like .2 sec, so in the fail case of a proc holding the lock for it's full lifetime, the user's request is only delayed by 1 sec by default.
Comment #7
Anonymous (not verified) commentedhere's a patch that implements the suggestions in #6.
Comment #8
pwolanin commentedThis looks good, assuming the test comes back green again
Comment #9
catchLooks sensible to me.
Comment #10
damien tournoud commentedI still don't get why we don't just proceed if we cannot acquire the lock. Sounds *a lot* more sensible to me than retrying.
Comment #11
Anonymous (not verified) commentedre #10 - putting this in settings.php achieves that:
Comment #12
deviantintegral commentedlock_wait($name, 0.2);lock_wait() takes an integer, not a float. Are you running with #2096259: Allow subsecond delays for lock_wait? It looks like it would still work even though it doesn't match the docs.
Comment #13
pwolanin commentedindeed, we need that patch first.
Comment #14
Anonymous (not verified) commentedre #12 - good point, updated patch to include changes to lock_wait to make it consistent.