]> git.sur5r.net Git - bacula/bacula/blob - bacula/patches/2.4.3-migrate-log.patch
ebl Be sure that wait_time is set before using it
[bacula/bacula] / bacula / patches / 2.4.3-migrate-log.patch
1 Index: src/dird/migrate.c
2 ===================================================================
3 --- src/dird/migrate.c  (revision 7926)
4 +++ src/dird/migrate.c  (working copy)
5 @@ -402,14 +402,6 @@
6     }
7  
8     migration_cleanup(jcr, jcr->JobStatus);
9 -   if (mig_jcr) {
10 -      char jobid[50];
11 -      UAContext *ua = new_ua_context(jcr);
12 -      edit_uint64(jcr->previous_jr.JobId, jobid);
13 -      /* Purge all old file records, but leave Job record */
14 -      purge_files_from_jobs(ua, jobid);
15 -      free_ua_context(ua);
16 -   }
17     return true;
18  }
19  
20 @@ -1087,11 +1079,26 @@
21           edit_uint64(mig_jcr->jr.JobId, ec2));
22        db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
23  
24 -      /* Now mark the previous job as migrated if it terminated normally */
25 -      if (jcr->JobStatus == JS_Terminated) {
26 +      /*
27 +       * If we terminated a migration normally:
28 +       *   - mark the previous job as migrated
29 +       *   - move any Log records to the new JobId
30 +       *   - Purge the File records from the previous job
31 +       */
32 +      if (jcr->JobType == JT_MIGRATE && jcr->JobStatus == JS_Terminated) {
33 +         char old_jobid[50], new_jobid[50];
34           Mmsg(query, "UPDATE Job SET Type='%c' WHERE JobId=%s",
35 -              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, ec1));
36 +              (char)JT_MIGRATED_JOB, edit_uint64(jcr->previous_jr.JobId, new_jobid));
37           db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
38 +         UAContext *ua = new_ua_context(jcr);
39 +         /* Move JobLog to new JobId */
40 +         Mmsg(query, "UPDATE Log SET JobId=%s WHERE JobId=%s",
41 +           new_jobid,
42 +           edit_uint64(jcr->previous_jr.JobId, old_jobid));
43 +         db_sql_query(mig_jcr->db, query.c_str(), NULL, NULL);
44 +         /* Purge all old file records, but leave Job record */
45 +         purge_files_from_jobs(ua, old_jobid);
46 +         free_ua_context(ua);
47        } 
48  
49        if (!db_get_job_record(jcr, jcr->db, &jcr->jr)) {
50 @@ -1100,7 +1107,6 @@
51           set_jcr_job_status(jcr, JS_ErrorTerminated);
52        }
53  
54 -
55        update_bootstrap_file(mig_jcr);
56  
57        if (!db_get_job_volume_names(mig_jcr, mig_jcr->db, mig_jcr->jr.JobId, &mig_jcr->VolumeName)) {