From: Kern Sibbald Date: Sat, 13 Dec 2008 13:29:13 +0000 (+0000) Subject: kes Fix Migration bug #1206 sql error with NULL FileSetId when no jobs X-Git-Tag: Release-7.0.0~3641 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=c17b907fa1426f06d9d64ad4f4e10ae9887f9dde;p=bacula%2Fbacula kes Fix Migration bug #1206 sql error with NULL FileSetId when no jobs to migrate. kes Fix Migration JobLog bug #1171. Get the JobIds correct. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@8151 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index bf20d4ba03..655c5a30fd 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -129,6 +129,12 @@ bool do_migration_init(JCR *jcr) Dmsg2(dbglevel, "Read pool=%s (From %s)\n", jcr->rpool->name(), jcr->rpool_source); + if (!get_or_create_fileset_record(jcr)) { + Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId); + Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n")); + return false; + } + /* If we find a job or jobs to migrate it is previous_jr.JobId */ count = get_job_to_migrate(jcr); if (count < 0) { @@ -146,12 +152,6 @@ bool do_migration_init(JCR *jcr) return true; /* no work */ } - if (!get_or_create_fileset_record(jcr)) { - Dmsg1(dbglevel, "JobId=%d no FileSet\n", (int)jcr->JobId); - Jmsg(jcr, M_FATAL, 0, _("Could not get or create the FileSet record.\n")); - return false; - } - create_restore_bootstrap_file(jcr); if (jcr->previous_jr.JobId == 0 || jcr->ExpectedFiles == 0) { @@ -1113,6 +1113,11 @@ void migration_cleanup(JCR *jcr, int TermCode) * mig_jcr is jcr of the newly migrated job. */ if (mig_jcr) { + char old_jobid[50], new_jobid[50]; + + edit_uint64(jcr->previous_jr.JobId, old_jobid); + edit_uint64(mig_jcr->jr.JobId, new_jobid); + mig_jcr->JobFiles = jcr->JobFiles = jcr->SDJobFiles; mig_jcr->JobBytes = jcr->JobBytes = jcr->SDJobBytes; mig_jcr->VolSessionId = jcr->VolSessionId; @@ -1127,7 +1132,7 @@ void migration_cleanup(JCR *jcr, int TermCode) "JobTDate=%s WHERE JobId=%s", jcr->previous_jr.cStartTime, jcr->previous_jr.cEndTime, edit_uint64(jcr->previous_jr.JobTDate, ec1), - edit_uint64(mig_jcr->jr.JobId, ec2)); + new_jobid); db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL); /* @@ -1137,15 +1142,13 @@ void migration_cleanup(JCR *jcr, int TermCode) * - Purge the File records from the previous job */ if (jcr->get_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, new_jobid)); + (char)JT_MIGRATED_JOB, old_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)); + new_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); diff --git a/bacula/src/version.h b/bacula/src/version.h index 562333e73e..1c5555b4e4 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -3,9 +3,9 @@ */ #undef VERSION -#define VERSION "2.5.22" -#define BDATE "01 December 2008" -#define LSMDATE "01Dec08" +#define VERSION "2.5.23" +#define BDATE "13 December 2008" +#define LSMDATE "13Dec08" #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.5 b/bacula/technotes-2.5 index 9463544758..1a9af7b0fa 100644 --- a/bacula/technotes-2.5 +++ b/bacula/technotes-2.5 @@ -10,6 +10,10 @@ filepattern (restore with regex in bsr) mixed priorities General: +13Dec08 +kes Fix Migration bug #1206 sql error with NULL FileSetId when no jobs + to migrate. +kes Fix Migration JobLog bug #1171. Get the JobIds correct. 12Dec08 ebl Fix segfault in bscan when using debug mode 11Dec08