Results 1 to 3 of 3

Thread: Does your get_inbound_mails scheduler hang on 'In Progress'?

  1. #1
    imclean is offline Junior Member
    Join Date
    Jun 2008
    Posts
    4

    Default Does your get_inbound_mails scheduler hang on 'In Progress'?

    Funny old thing, but its because of some poor programming:

    In the modules. schedulers folder there is a file called scheduler.php where they check for dead or hung processes:

    They use a function with is_resource which will always return as null so it never fires, thus you never get out of the 'In Progress' status.

    Change it to:

    function flushDeadJobs() {
    $GLOBALS['log']->debug('-----> Scheduler flushing dead jobs');

    $lowerLimit = mktime(0, 0, 0, 1, 1, 2005); // jan 01, 2005, GMT-0
    $now = strtotime(gmdate('Y-m-d H:i:s', strtotime('now'))); // this garbage to make sure we're getting comprable data to the DB output

    $q = " SELECT s.id, s.name FROM schedulers s WHERE s.deleted=0 AND s.status = 'In Progress'";
    $r = $this->db->query($q);

    if($r != null) {
    while($a = $this->db->fetchByAssoc($r)) {
    $q2 = " SELECT st.id, st.execute_time FROM schedulers_times st
    WHERE st.deleted=0
    AND st.scheduler_id = '{$a['id']}'
    ORDER BY st.execute_time DESC";
    $r2 = $this->db->query($q2);
    if($r2 != null) {
    $a2 = $this->db->fetchByAssoc($r2); // we only care about the newest
    if($a2 != null) {
    $GLOBALS['log']->debug("-----> Scheduler found [ {$a['name']} ] 'In Progress' with most recent Execute Time at [ {$a2['execute_time']} GMT-0 ]");

    $execTime = strtotime($a2['execute_time']);
    if($execTime > $lowerLimit) {
    if(($now - $execTime) >= (5 * $this->timeOutMins)) {
    $GLOBALS['log']->info("-----> Scheduler found a dead Job. Flushing status and reseting Job");
    $q3 = "UPDATE schedulers s SET s.status = 'Active' WHERE s.id = '{$a['id']}'";
    $this->db->query($q3);

    $GLOBALS['log']->info("-----> Scheduler setting Job Instance status to 'failed'");
    $q4 = "UPDATE schedulers_times st SET st.status = 'failed' WHERE st.id = '{$a2['id']}';";
    $this->db->query($q4);
    } else {
    $GLOBALS['log']->debug("-----> Scheduler will wait for job to complete - not past threshold of [ ".($this->timeOutMins * 60)."secs ] - timeDiff is ".($now - $execTime)." secs");
    }
    } else {
    $GLOBALS['log']->fatal("-----> Scheduler got a bad execute time: [ {$a2['execute_time']} GMT-0 ]");
    }

    }
    }
    }
    }
    }

    There are 3 instances of this, I tested it and it works now.

    Regards,

    Iain
    Last edited by imclean; 2008-08-19 at 01:19 PM.

  2. #2
    spencerm is offline Sugar Community Member
    Join Date
    Aug 2007
    Posts
    28

    Default Re: Does your get_inbound_mails scheduler hang on 'In Progress'?

    That is great! We had that issue for about a week. Thanks for your help!

  3. #3
    clint's Avatar
    clint is offline Sugar Team Member | Forums Lead Moderator
    Join Date
    Aug 2004
    Location
    Silicon Valley
    Posts
    2,120

    Default Re: Does your get_inbound_mails scheduler hang on 'In Progress'?

    Great catch. I've filed bug 24349 to track this and nominated it for the next 5.0.0 patch.
    Sugar Developer Zone - developer resources | Sugar University - user and admin training
    Sugar Docs - user and admin documentation |
    Sugar Bug Tracker - Enter or view bugs
    SugarForge- open source modules, themes, lang packs | SugarExchange - commercial extensions

    Clint Oram
    Chief Technology Officer and Co-founder
    SugarCRM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. ZuckerReports Scheduler failure
    By MGregson in forum Help
    Replies: 7
    Last Post: 2009-10-08, 03:49 AM
  2. Replies: 13
    Last Post: 2009-08-11, 01:10 PM
  3. Scheduler Dates Incorrect
    By mmakowski in forum Help
    Replies: 3
    Last Post: 2007-01-06, 06:52 AM
  4. Inbox poller scheduler stops running
    By trueblade in forum Help
    Replies: 4
    Last Post: 2006-05-21, 11:47 PM
  5. Inbound Email Scheduler Bug ?
    By kokwei in forum Help
    Replies: 8
    Last Post: 2006-05-15, 06:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •