]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Turn on cleanup_incomplete()
authorKern Sibbald <kern@sibbald.com>
Thu, 16 May 2019 15:43:41 +0000 (17:43 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 18 May 2019 14:06:09 +0000 (16:06 +0200)
bacula/src/dird/backup.c
regress/scripts/functions.pm

index 55f01b671cd3ed07babc0f728d7fa38db25170d9..9c39ae4284e36b986b612e7c37f838fe7552325a 100644 (file)
@@ -779,9 +779,6 @@ int wait_for_job_termination(JCR *jcr, int timeout)
    return jcr->SDJobStatus;
 }
 
-/* Not used */
-#if 0
-
 /* When the job is incomplete, we need to make sure the catalog
  * is consistent. The JobMedia table should reference Files that
  * are not in the file table for example.
@@ -868,7 +865,6 @@ bail_out:
    db_end_transaction(jcr, jcr->db);
    db_unlock(jcr->db);
 }
-#endif
 
 /*
  * Release resources allocated during backup.
@@ -891,10 +887,8 @@ void backup_cleanup(JCR *jcr, int TermCode)
 
    remove_dummy_jobmedia_records(jcr);
 
-#if 0
    /* cleanup the job media table after an incomplete job, should not be needed */
    incomplete_cleanup(jcr);
-#endif
 
    if (jcr->is_JobLevel(L_VIRTUAL_FULL)) {
       vbackup_cleanup(jcr, TermCode);
@@ -1158,7 +1152,8 @@ void update_bootstrap_file(JCR *jcr)
          /* Start output with when and who wrote it */
          bstrftimes(edt, sizeof(edt), time(NULL));
          fprintf(fd, "# %s - %s - %s%s\n", edt, jcr->jr.Job,
-                 level_to_str(edl, sizeof(edl), jcr->getJobLevel()), jcr->since);
+                 level_to_str(edl, sizeof(edl), jcr->getJobLevel()),
+                 jcr->since);
          for (int i=0; i < VolCount; i++) {
             /* Write the record */
             fprintf(fd, "Volume=\"%s\"\n", VolParams[i].VolumeName);
index 2942980c3db40d7afb363b65bd4016d5e18a204b..2c4f52240bf02c62be357fa37bfe48fed6fe89f6 100644 (file)
@@ -446,7 +446,10 @@ sub check_jobmedia
     open(FP, "|$bin/bconsole -c $conf/bconsole.conf >$tmp/check_jobmedia.$$");
     print FP "\@echo File generated by scripts::function::check_jobmedia()\n";
     print FP "sql\n";
-    print FP "SELECT 'ERROR with FirstIndex not starting at 1 (JobId|FirstIndex)', JobId, Min(FirstIndex) AS A FROM JobMedia GROUP BY JobId HAVING Min(FirstIndex) > 1;\n";
+    if ($TestName !~ /(restart|incomplete)-/) {
+        print FP "SELECT 'ERROR with FirstIndex not starting at 1 (JobId|FirstIndex)', JobId, Min(FirstIndex) AS A FROM JobMedia GROUP BY JobId HAVING Min(FirstIndex) > 1;\n";
+    }
+    print FP "SELECT 'ERROR with FirstIndex greater than LastIndex', JobId, JobMediaId, FirstIndex, LastIndex FROM JobMedia WHERE FirstIndex > LastIndex;\n";
     print FP "SELECT 'ERROR with LastIndex != JobFiles (JobId|LastIndex|JobFiles)', JobId, Max(LastIndex), JobFiles FROM Job JOIN JobMedia USING (JobId) WHERE JobStatus = 'T' AND Type = 'B' GROUP BY JobId,JobFiles HAVING Max(LastIndex) != JobFiles;\n";
     print FP "SELECT 'Index', JobId, FirstIndex, LastIndex, JobMediaId FROM JobMedia ORDER BY JobId, JobMediaId;\n";
     print FP "SELECT 'Block', JobId, MediaId, StartFile, EndFile, StartBlock, EndBlock, JobMediaId FROM JobMedia ORDER BY JobId, JobMediaId;\n";
@@ -474,6 +477,10 @@ sub check_jobmedia
         } elsif ($l =~ /Index\s*!\s*(\d+)\s*!\s*(\d+)\s*!\s*(\d+)\s*!/) {
             my ($jobid, $first, $last) = ($1, $2, $3);
 
+            # incomplete tests are creating gaps in the FileIndex, no need to report these errors
+            next if ($TestName =~ /(restart|incomplete)[0-9]?-/);
+
+            # Skip dummy records
             next if ($first == 0 && $last == 0);
 
             if ($jobs{$jobid} && !($jobs{$jobid} == $first || $jobs{$jobid} == ($first - 1))) {