]> git.sur5r.net Git - bacula/bacula/commitdiff
Migrate DB Log records too. This fixes last part of bug #1171.
authorKern Sibbald <kern@sibbald.com>
Thu, 30 Oct 2008 12:07:44 +0000 (12:07 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 30 Oct 2008 12:07:44 +0000 (12:07 +0000)
git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@7951 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/src/dird/migrate.c
bacula/src/version.h
bacula/technotes-2.4

index 5776f2364e6cda7ace511ee0aefeb8e1e7da0f00..1c695e2033221d36bab7e66a3cd25b6e70654987 100644 (file)
@@ -402,14 +402,6 @@ bool do_migration(JCR *jcr)
    }
 
    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 @@ void migration_cleanup(JCR *jcr, int TermCode)
          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 @@ void migration_cleanup(JCR *jcr, int TermCode)
          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)) {
index 61a934bf6bb02dec301a26ccd28f3cc574c24907..13204b757547bb4c0aabf56ac395898dbd186b26 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "2.4.3"
-#define BDATE   "24 October 2008"
-#define LSMDATE "24Oct08"
+#define BDATE   "28 October 2008"
+#define LSMDATE "28Oct08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index 3ae66c18f57f2fe47ecf87a95fc9733b476db3af..ad731442d2b064c69ee3af9ad6ec6f80f08bfcda 100644 (file)
@@ -1,6 +1,8 @@
               Technical notes on version 2.4
 
 General:
+28Oct08
+kes  Migrate DB Log records too. This fixes last part of bug #1171.
 24Oct08
 kes  Modify SQL so that jobs that failed will not be migrated.
 kes  Correct bug where long retention periods caused immediate