From 7f32667113a0fd8acabbb5523cb5744857657b57 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 30 Oct 2008 12:07:44 +0000 Subject: [PATCH] Migrate DB Log records too. This fixes last part of bug #1171. 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 | 30 ++++++++++++++++++------------ bacula/src/version.h | 4 ++-- bacula/technotes-2.4 | 2 ++ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 5776f2364e..1c695e2033 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -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)) { diff --git a/bacula/src/version.h b/bacula/src/version.h index 61a934bf6b..13204b7575 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 */ diff --git a/bacula/technotes-2.4 b/bacula/technotes-2.4 index 3ae66c18f5..ad731442d2 100644 --- a/bacula/technotes-2.4 +++ b/bacula/technotes-2.4 @@ -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 -- 2.39.5