In drupal_cron_cleanup() there is use of 'cron_semaphore' in the variable table and a search through all the code using my IDE shows no reference from any other function anywhere in Drupal using this variable. In other words -- it's totally useless code.

However, a lock for the cron IS obtained in drupal_cron_run() through the lock_acquire() and released through lock_release() -- a completely different methodology.

I believe this is going to require someone looking through the code and verifying my findings because waiting for symptoms to show this finding may never happen since the functions in lock.inc have their own time limit code. That means that even though the code in drupal_cron_cleanup() looks useless it may actually never be needed except under weird circumstances.

One example I could think where drupal_cron_cleanup() might still be useful is if Drupal crashed in the middle of a cron run because of bad code in an add-in module but then you are relying on one problem to surface to find another which is not a great way to go.

They are both really short functions and would take but a moment to look at and compare. Here they are:
http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_cron_cleanup/7
http://api.drupal.org/api/drupal/includes!common.inc/function/drupal_cron_run/7

Anyway, I hope someone can take a quick look at let me know if they agree or not with what I have found.

There is a patch and more detail here:
http://drupal.org/node/1253370#comment-6425498

Comments

Jooblay.net’s picture

Thanks for the follow up Reg:) I will download the patch and hit late night:) i am a little slow at the moment i have 4 sites going live this next week...

thanks again for the set!

just a note:( i was going to add a forum for a possible idea about getting drupal_abuser going... we have ran across a host of companies abusing drupal developers in the last couple months... not paying them:( abuser.drupal.org? then we can plug and run our jobs against the site? just a thought:) It really begs for a larger abuser /index.php :)

Reg’s picture

I think your forum is a great idea.

jacobpov’s picture

having drupal cron issues this might solve something but afraid to test on a live site :(

Reg’s picture

Don't be. If you look at the code you will see that it can help but can't hurt. In other words you can gain although you may not but you can't lose.

I have about 50 Drupal websites on a multi-site install and I use this patch, if there was going to be a problem I'm pretty sure I would have experienced it by now.

jacobpov’s picture

okay I have applied the patch still nothing

Type Datesort ascending Message User Operations
cron 10/02/2012 - 04:12 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:12 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:12 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:12 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:11 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:11 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:11 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:11 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:11 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:11 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:10 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:09 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:09 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)
cron 10/02/2012 - 04:08 Attempting to re-run cron while it is already running. Anonymous (not verified)

my cron error log .... there is definatly something wrong with my cron , it didn't run for 3 days now

Reg’s picture

Without actually seeing your setup such as ssh'ing into your server I can't really tell you what your problem is but my guess is that you have some broken PHP somewhere in a cron hook.

My first step in figuring out what is happening if I was you would be to tail your PHP error log on your server and see what it says. Also at the top of your crontab you could add: mailto:YourEmailAddress and you should get emailed any and all cronjobs that are putting out any text which should only happen if there are errors.

BTW, were you getting those messages before or after applying the patch?

Reg’s picture

Why do you have 9 errors for the same time? It looks like you have 9 cronjobs trying to do the same thing at the same time, that would certainly cause problems.

Also, you might want to spread out your cronjob so it's not running so often. Right now it looks like it's running every two minutes and it could easily overlap like that depending on your website & server combination so those errors could be legit in that case -- but not that many in any given minute, that's another issue that needs to be looked into.

You might want to pair it back to once every 5, 10, 15 or 30 mins. Basically, as rarely as you can get away with without messing up something that needs to happen regularly.

From memory I run mine every 20 mins. or so and many people get away with once an hour without any problem whatsoever.

jacobpov’s picture

I've had them before applying the patch .I couldn't setup the mail functionality on my server so I am not sure I'll be able to do that . I have restarted the server a lot recently because of continuous server crushes that I've had with php-FPM + nigix taking up memory, Now a little more stable but cron completely broke.

Reg’s picture

While you are having such crashes and instability you should probably also have your server start with a file system check each time it starts. Otherwise you could have file system problems and they often look like completely different types of errors so you never know they're the source of your problems until it's too late.

jacobpov’s picture

[02-Oct-2012 10:13:57] WARNING: [pool www] child 19886 exited on signal 15 (SIGTERM) after 425.733913 seconds from start
[02-Oct-2012 10:13:57] NOTICE: [pool www] child 20275 started
[02-Oct-2012 10:17:17] WARNING: [pool www] child 20186, script '/var/www/index.php' (request: "GET /index.php") execution timed out (302.807317 sec), terminating
[02-Oct-2012 10:17:18] WARNING: [pool www] child 20186 exited on signal 15 (SIGTERM) after 320.070922 seconds from start
[02-Oct-2012 10:17:18] NOTICE: [pool www] child 21569 started
[02-Oct-2012 10:22:17] WARNING: [pool www] child 20401, script '/var/www/index.php' (request: "GET /index.php") execution timed out (355.343666 sec), terminating
[02-Oct-2012 10:22:17] WARNING: [pool www] child 20401 exited on signal 15 (SIGTERM) after 419.628179 seconds from start
[02-Oct-2012 10:22:17] NOTICE: [pool www] child 21868 started
[02-Oct-2012 10:25:37] WARNING: [pool www] child 21663, script '/var/www/index.php' (request: "GET /index.php") execution timed out (311.377790 sec), terminating
[02-Oct-2012 10:25:37] WARNING: [pool www] child 21663 exited on signal 15 (SIGTERM) after 360.453277 seconds from start
[02-Oct-2012 10:25:37] NOTICE: [pool www] child 22193 started
[02-Oct-2012 10:30:37] WARNING: [pool www] child 22003, script '/var/www/index.php' (request: "GET /index.php") execution timed out (376.348383 sec), terminating
[02-Oct-2012 10:30:59] WARNING: [pool www] child 22003 exited on signal 15 (SIGTERM) after 398.009056 seconds from start
[02-Oct-2012 10:30:59] NOTICE: [pool www] child 22496 started
[02-Oct-2012 10:33:57] WARNING: [pool www] child 22287, script '/var/www/index.php' (request: "GET /index.php") execution timed out (325.566737 sec), terminating
[02-Oct-2012 10:33:57] WARNING: [pool www] child 22287 exited on signal 15 (SIGTERM) after 373.258738 seconds from start
[02-Oct-2012 10:33:57] NOTICE: [pool www] child 23697 started

I keep getting these errors , I checked the php-FPM log
you have a clue why would that be so ?

jacobpov’s picture

Mailing fixed , so how exactly do I add the mailto and where is the crontab ?.

thanks!.

Reg’s picture

I use Apache and OpenSuse so your system is not something with which I am familiar. Also, your questions are starting to go into the realm of a different forum. If you are using Ubuntu or something like that, that's where I would ask about those errors.

As for cron/mailto, a web search will give you plenty of examples such as this: http://www.pantz.org/software/cron/croninfo.html

jacobpov’s picture

Okay I was saved today , Heartbeat was interuppting cron . with the help of this module http://drupal.org/project/cron_debug

I got everything solved :) .

Jooblay.net’s picture

Thanks for the nore:) we have found this issue with Backup_Migrate module as well. Check both modules sound like?

Thanks again...

shortspoken’s picture

Thanks. #13 worked for me.

Berdir’s picture

Status: Active » Closed (duplicate)