]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/dird/job.c
Fix bug #1307 AllowHigherDuplicates=no prevents automatic job escalation
[bacula/bacula] / bacula / src / dird / job.c
index 4329a76f2e7a072d030ad1d0b9ed083f3757fdf5..3b84fd98e9f7646cfb2fb2427f8bb0f497ad21c8 100644 (file)
@@ -506,7 +506,7 @@ static void job_monitor_watchdog(watchdog_t *self)
    foreach_jcr(jcr) {
       bool cancel = false;
 
-      if (jcr->JobId == 0 || job_canceled(jcr)) {
+      if (jcr->JobId == 0 || job_canceled(jcr) || jcr->no_maxtime) {
          Dmsg2(800, "Skipping JCR=%p Job=%s\n", jcr, jcr->Job);
          continue;
       }
@@ -578,6 +578,7 @@ static bool job_check_maxruntime(JCR *jcr)
 {
    bool cancel = false;
    JOB *job = jcr->job;
+   utime_t run_time;
 
    if (job_canceled(jcr) || jcr->JobStatus == JS_Created) {
       return false;
@@ -586,20 +587,25 @@ static bool job_check_maxruntime(JCR *jcr)
        job->IncMaxRunTime == 0 && job->DiffMaxRunTime == 0) {
       return false;
    }
-   Dmsg6(200, "check_maxruntime %u - %u >= %u|%u|%u|%u\n\n",
-         watchdog_time, jcr->start_time, job->MaxRunTime, job->FullMaxRunTime, 
+   run_time = watchdog_time - jcr->start_time;
+   Dmsg7(200, "check_maxruntime %llu-%u=%llu >= %llu|%llu|%llu|%llu\n",
+         watchdog_time, jcr->start_time, run_time, job->MaxRunTime, job->FullMaxRunTime, 
          job->IncMaxRunTime, job->DiffMaxRunTime);
 
    if (jcr->get_JobLevel() == L_FULL && job->FullMaxRunTime != 0 &&
-         (watchdog_time - jcr->start_time) >= job->FullMaxRunTime) {
+         run_time >= job->FullMaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: FullMaxcancel\n");
       cancel = true;
    } else if (jcr->get_JobLevel() == L_DIFFERENTIAL && job->DiffMaxRunTime != 0 &&
-         (watchdog_time - jcr->start_time) >= job->DiffMaxRunTime) {
+         run_time >= job->DiffMaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: DiffMaxcancel\n");
       cancel = true;
    } else if (jcr->get_JobLevel() == L_INCREMENTAL && job->IncMaxRunTime != 0 &&
-         (watchdog_time - jcr->start_time) >= job->IncMaxRunTime) {
+         run_time >= job->IncMaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: IncMaxcancel\n");
       cancel = true;
-   } else if ((watchdog_time - jcr->start_time) >= job->MaxRunTime) {
+   } else if (job->MaxRunTime > 0 && run_time >= job->MaxRunTime) {
+      Dmsg0(200, "check_maxwaittime: Maxcancel\n");
       cancel = true;
    }
  
@@ -666,6 +672,9 @@ bool allow_duplicate_job(JCR *jcr)
    if (!job->AllowHigherDuplicates) {
       foreach_jcr(djcr) {
          char ec1[50];
+         if (jcr == djcr) {
+            continue;                   /* do not cancel this job */
+         }
          if (strcmp(job->name(), djcr->job->name()) == 0) {
             bool cancel_queued = false;
             if (job->DuplicateJobProximity > 0) {