]> git.sur5r.net Git - bacula/bacula/commitdiff
Commit patches
authorKern Sibbald <kern@sibbald.com>
Thu, 30 Oct 2008 12:07:03 +0000 (12:07 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 30 Oct 2008 12:07:03 +0000 (12:07 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@7950 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/patches/2.4.3-migrate-log.patch [new file with mode: 0644]

diff --git a/bacula/patches/2.4.3-migrate-log.patch b/bacula/patches/2.4.3-migrate-log.patch
new file mode 100644 (file)
index 0000000..a35f815
--- /dev/null
@@ -0,0 +1,57 @@
+Index: src/dird/migrate.c
+===================================================================
+--- src/dird/migrate.c (revision 7926)
++++ src/dird/migrate.c (working copy)
+@@ -402,14 +402,6 @@
+    }
+    migration_cleanup(jcr, jcr->JobStatus);
+-   if (mig_jcr) {
+-      char jobid[50];
+-      UAContext *ua = new_ua_context(jcr);
+-      edit_uint64(jcr->previous_jr.JobId, jobid);
+-      /* Purge all old file records, but leave Job record */
+-      purge_files_from_jobs(ua, jobid);
+-      free_ua_context(ua);
+-   }
+    return true;
+ }
+@@ -1087,11 +1079,26 @@
+          edit_uint64(mig_jcr->jr.JobId, ec2));
+       db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
+-      /* Now mark the previous job as migrated if it terminated normally */
+-      if (jcr->JobStatus == JS_Terminated) {
++      /*
++       * If we terminated a migration normally:
++       *   - mark the previous job as migrated
++       *   - move any Log records to the new JobId
++       *   - Purge the File records from the previous job
++       */
++      if (jcr->JobType == JT_MIGRATE && jcr->JobStatus == JS_Terminated) {
++         char old_jobid[50], new_jobid[50];
+          Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s",
+-              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1));
++              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, new_jobid));
+          db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
++         UAContext *ua = new_ua_context(jcr);
++         /* Move JobLog to new JobId */
++         Mmsg(query, "UPDATE Log SET JobId=%s WHERE JobId=%s",
++           new_jobid,
++           edit_uint64(jcr->previous_jr.JobId, old_jobid));
++         db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
++         /* Purge all old file records, but leave Job record */
++         purge_files_from_jobs(ua, old_jobid);
++         free_ua_context(ua);
+       } 
+       if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
+@@ -1100,7 +1107,6 @@
+          set_jcr_job_status(jcr, JS_ErrorTerminated);
+       }
+-
+       update_bootstrap_file(mig_jcr);
+       if (!db_get_job_volume_names(mig_jcr, mig_jcr->db, mig_jcr->jr.JobId, &mig_jcr->VolumeName)) {