Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Because cron_semaphore is an unreliable piece of crap.
Comment | File | Size | Author |
---|---|---|---|
#22 | cron_lock_D6.patch | 1.77 KB | catch |
#12 | cron_locking_240_with_update.patch | 2.7 KB | Berdir |
#10 | cron_locking_240.patch | 2.2 KB | Berdir |
#10 | cron_locking_900.patch | 2.2 KB | Berdir |
#3 | cron_locking.patch | 2.2 KB | Berdir |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedI though we did that already. Crap.
Comment #2
catchFor a moment I thought the HEAD install I was looking at was from before a patch went in, but http://api.drupal.org/api/function/drupal_cron_run/7 dashed my hopes.
Comment #3
BerdirYes, I'm wondering too if this is going to work, seems almost too easy :) Maybe we want to lower the timeframe to something less than a whole hour?
Comment #4
Dries CreditAttribution: Dries commentedOK with me. (I thought we had a use issue about this already.)
Comment #5
BerdirYeah there is/was: #553600: Apply locking framework to cron runs.
That issue had never a patch however, so I marked it as a duplicate.
Comment #6
catchMaybe 15 minutes for the lock_acquire()? Even less? Patch looks good and I think we already have some cron tests.
Comment #7
Dries CreditAttribution: Dries commentedI agree that one hour is rather long and that 15 minutes should be plenty.
(It's odd that lock_acquire() takes a float.)
Comment #8
BerdirCurrently, we set the time limit to only 240, is there any reason why the locking should have a different value? (not saying that we should change it to 240, but simply the same value...)
lock_acquire() can handle lock times which are less than 1s, that is why it takes a float.
Comment #9
catchMarked #146551: Reset cron_semaphore when cron is run manually in admin/reports/status
Comment #10
BerdirOk, here are two patches. One with timeout of 900s and another with 240s.
Comment #11
catch240s seems right. We should have a hook_update_N() to remove the cron_semaphore variable though, apart from that look RTBC to me.
Comment #12
BerdirThere you go ;)
Comment #13
catchComment #14
Dries CreditAttribution: Dries commentedCommitted to CVS HEAD. Thanks.
Comment #15
rfayI call this an API change because it changes how Drupal has always done business, affecting how people (or modules) may interact with the system.
Could you please summarize the impact of this patch on real Drupal users? (Besides "making life better").
Comment #16
catchThis shouldn't make any difference whatsoever. Only possibility is if there's some kind of module for unlocking the cron semaphore, which wouldn't surprise me since it's so annoying, this wouldn't be needed since the lock has a time limit. It also (along with the queue system) makes some of the super cron etc. modules a bit less useful than they should be, but those exist to work around how terrible the existing cron system is / has been.
Comment #17
Eric_A CreditAttribution: Eric_A commentedPretty sure this bug is in 6.x, too ;-)
EDIT: This semaphore removing probably cannot be backported. So I should not have changed the version number on this issue, then? If it is portable, then this can be set to open, I guess.
Comment #18
catchComment #19
Damien Tournoud CreditAttribution: Damien Tournoud commentedDrupal 6 is API frozen. -1 here.
Comment #20
David_Rothstein CreditAttribution: David_Rothstein commentedAs far as I understand, set_time_limit() only affects the actual PHP code execution time, which is not the same as the elapsed 'wall clock' time, which can be substantially different due to database queries, etc (see the note at http://php.net/manual/en/function.set-time-limit.php). So there is no particular reason why the lock should be held for only as long as the maximum script execution time.
Given that, I wonder if 240 seconds is a little too short for the lock? I think I have seen legitimate cron runs last around that long. It's probably not a huge deal, though.
Comment #21
ikeigenwijs CreditAttribution: ikeigenwijs commentedsubscribe, having cron troubles
Comment #22
catchI needed a backport of this for a client site, here it is.
Comment #23
fagoYep, it can be problematic though. I've seen a lot of concurrent cron runs piling up on a site because of this, see #2319177: Cron lock time limit is too short and does not prevent multiple, concurrent cron runs.