If a cron function causes an exception, it's lock isn't removed

Bug #685640 reported by Andrew Nicols
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mahara
Fix Released
Medium
Richard Mansfield

Bug Description

Came across this whilst looking at #685633 but thought that it deserved a separate bug.
If a cron function causes an exception for whatever reason, then the cron will stop, but the lock isn't removed. The job then isn't tried again for another 24 hours.

Whilst this is possibly correct in some fashions -- e.g. broken crons aren't run endlessly to no point, some crons may cause an exception once in a while which isn't a major issue but shouldn't mean that the cron doesn't take place for another 24 hours.
For example, network issues will probably cause the cron_check_for_updates cron to fail, but this could be a transient issue.

Not sure whether it's best to catch the errors and alert an administrator but still keep the lock in place (to prevent the admin from being spammed), or to catch the errors and assume that they may be transient and try again, or some other solution...

Changed in mahara:
importance: Low → Medium
status: New → Triaged
Revision history for this message
Hugh Davenport (hugh-davenport) wrote :

also related to bug 776955

Changed in mahara:
status: Triaged → In Progress
assignee: nobody → Richard Mansfield (richard-mansfield)
milestone: none → 1.5.0
Revision history for this message
Mahara Bot (dev-mahara) wrote : A change has been merged

Reviewed: https://reviews.mahara.org/1054
Committed: http://gitorious.org/mahara/mahara/commit/ae76bab037afe6af75c5180bc3137d5770df316f
Submitter: Francois Marier (<email address hidden>)
Branch: master

commit ae76bab037afe6af75c5180bc3137d5770df316f
Author: Richard Mansfield <email address hidden>
Date: Thu Feb 16 10:45:02 2012 +1300

    Try to remove lock when exception thrown in cron function (bug #685640)

    If a cron function causes an exception for whatever reason, then the
    cron will stop, but the lock isn't removed. The job then isn't tried
    again for another 24 hours.

    Instead we should try to set the next run time and remove the lock.
    Cron functions that run frequently, but fail due to some temporary
    problem, will not be forced to stop for 24 hours. On the other hand,
    very frequent cron functions that throw exceptions on every run will
    be spammy.

    Obviously, this change has no effect on cron functions that fail due
    to script timeouts, out-of-memory errors, or which exit for any other
    reason.

    Change-Id: I3bfe08c2ebba62cbd82045e66438a6442d1f1fe8
    Signed-off-by: Richard Mansfield <email address hidden>

Changed in mahara:
status: In Progress → Fix Committed
Melissa Draper (melissa)
Changed in mahara:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.