]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Modify SQL so that jobs that failed will not be migrated.
authorKern Sibbald <kern@sibbald.com>
Tue, 28 Oct 2008 19:51:46 +0000 (19:51 +0000)
committerKern Sibbald <kern@sibbald.com>
Tue, 28 Oct 2008 19:51:46 +0000 (19:51 +0000)
kes  Correct bug where long retention periods caused immediate
     prunning.

git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/branches/Branch-2.4@7926 91ce42f0-d328-0410-95d8-f526ca767f89

bacula/patches/2.4.3-migrate.patch [new file with mode: 0644]
bacula/patches/2.4.3-prune.patch [new file with mode: 0644]
bacula/src/dird/migrate.c
bacula/src/dird/ua_prune.c
bacula/src/version.h
bacula/technotes-2.4

diff --git a/bacula/patches/2.4.3-migrate.patch b/bacula/patches/2.4.3-migrate.patch
new file mode 100644 (file)
index 0000000..138c09c
--- /dev/null
@@ -0,0 +1,53 @@
+
+ This patch should prevent migration jobs from attempting to migrate
+ jobs that failed.  Apply it to Bacula 2.4.3 (possibly earlier versions)
+ with:
+
+ cd <bacula-source>
+ patch -p0 <2.4.3-migrate.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+
+Index: src/dird/migrate.c
+===================================================================
+--- src/dird/migrate.c (revision 7757)
++++ src/dird/migrate.c (working copy)
+@@ -377,7 +377,7 @@
+     * to avoid two threads from using the BSOCK structure at
+     * the same time.
+     */
+-   if (!bnet_fsend(sd, "run")) {
++   if (!sd->fsend("run")) {
+       return false;
+    }
+@@ -520,6 +520,7 @@
+    "SELECT DISTINCT Job.JobId,Job.StartTime FROM Job,Pool,Client"
+    " WHERE Client.Name='%s' AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId"
+    " AND Job.ClientId=Client.ClientId AND Job.Type='B'"
++   " AND Job.JobStatus = 'T'"
+    " ORDER by Job.StartTime";
+ /* Get Volume names in Pool */
+@@ -533,9 +534,9 @@
+    "SELECT DISTINCT Job.JobId,Job.StartTime FROM Media,JobMedia,Job"
+    " WHERE Media.VolumeName='%s' AND Media.MediaId=JobMedia.MediaId"
+    " AND JobMedia.JobId=Job.JobId AND Job.Type='B'"
++   " AND Job.JobStatus = 'T' AND Media.Enabled=1"
+    " ORDER by Job.StartTime";
+-
+ const char *sql_smallest_vol = 
+    "SELECT Media.MediaId FROM Media,Pool,JobMedia WHERE"
+    " Media.MediaId in (SELECT DISTINCT MediaId from JobMedia) AND"
+@@ -570,7 +571,6 @@
+ const char *sql_job_bytes =
+    "SELECT SUM(JobBytes) FROM Job WHERE JobId IN (%s)";
+-
+ /* Get Media Ids in Pool */
+ const char *sql_mediaids =
+    "SELECT MediaId FROM Media,Pool WHERE"
diff --git a/bacula/patches/2.4.3-prune.patch b/bacula/patches/2.4.3-prune.patch
new file mode 100644 (file)
index 0000000..7af00a7
--- /dev/null
@@ -0,0 +1,57 @@
+
+ This patch should fix the bug reported on the bacula-users list where
+ a retention period of 100 years does immediate prunning.
+ Apply it to 2.4.3 (or earlier versions) with:
+
+ cd <bacula-source>
+ patch -p0 <2.4.3-prune.patch
+ ./configure <your-options>
+ make
+ ...
+ make install
+
+Index: src/dird/ua_prune.c
+===================================================================
+--- src/dird/ua_prune.c        (revision 7757)
++++ src/dird/ua_prune.c        (working copy)
+@@ -202,7 +202,7 @@
+    now = (utime_t)time(NULL);
+    /* Select Jobs -- for counting */
+-   Mmsg(query, count_select_job, edit_uint64(now - period, ed1), 
++   Mmsg(query, count_select_job, edit_int64(now - period, ed1), 
+         edit_int64(cr.ClientId, ed2));
+    Dmsg3(050, "select now=%u period=%u sql=%s\n", (uint32_t)now, 
+                (uint32_t)period, query.c_str());
+@@ -230,7 +230,7 @@
+    del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids);
+    /* Now process same set but making a delete list */
+-   Mmsg(query, select_job, edit_uint64(now - period, ed1), 
++   Mmsg(query, select_job, edit_int64(now - period, ed1), 
+         edit_int64(cr.ClientId, ed2));
+    db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)&del);
+@@ -318,7 +318,7 @@
+     * Select all files that are older than the JobRetention period
+     *  and stuff them into the "DeletionCandidates" table.
+     */
+-   edit_uint64(now - period, ed1);
++   edit_int64(now - period, ed1);
+    Mmsg(query, insert_delcand, (char)JobType, ed1, 
+         edit_int64(cr.ClientId, ed2));
+    if (!db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL)) {
+@@ -443,10 +443,10 @@
+    edit_int64(mr->MediaId, ed1); 
+    period = mr->VolRetention;
+    now = (utime_t)time(NULL);
+-   edit_uint64(now-period, ed2);
++   edit_int64(now-period, ed2);
+    Mmsg(query, sel_JobMedia, ed1, ed2);
+-   Dmsg3(250, "Now=%d period=%d now-period=%d\n", (int)now, (int)period,
+-      (int)(now-period));
++   Dmsg3(250, "Now=%d period=%d now-period=%s\n", (int)now, (int)period,
++      ed2);
+    Dmsg1(050, "Query=%s\n", query.c_str());
+    if (!db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)del)) {
index 0327b018ffe80feb1bdb789c823c6859c7e5e7ce..5776f2364e6cda7ace511ee0aefeb8e1e7da0f00 100644 (file)
@@ -377,7 +377,7 @@ bool do_migration(JCR *jcr)
     * to avoid two threads from using the BSOCK structure at
     * the same time.
     */
-   if (!bnet_fsend(sd, "run")) {
+   if (!sd->fsend("run")) {
       return false;
    }
 
@@ -520,6 +520,7 @@ const char *sql_jobids_from_client =
    "SELECT DISTINCT Job.JobId,Job.StartTime FROM Job,Pool,Client"
    " WHERE Client.Name='%s' AND Pool.Name='%s' AND Job.PoolId=Pool.PoolId"
    " AND Job.ClientId=Client.ClientId AND Job.Type='B'"
+   " AND Job.JobStatus = 'T'"
    " ORDER by Job.StartTime";
 
 /* Get Volume names in Pool */
@@ -533,9 +534,9 @@ const char *sql_jobids_from_vol =
    "SELECT DISTINCT Job.JobId,Job.StartTime FROM Media,JobMedia,Job"
    " WHERE Media.VolumeName='%s' AND Media.MediaId=JobMedia.MediaId"
    " AND JobMedia.JobId=Job.JobId AND Job.Type='B'"
+   " AND Job.JobStatus = 'T' AND Media.Enabled=1"
    " ORDER by Job.StartTime";
 
-
 const char *sql_smallest_vol = 
    "SELECT Media.MediaId FROM Media,Pool,JobMedia WHERE"
    " Media.MediaId in (SELECT DISTINCT MediaId from JobMedia) AND"
@@ -570,7 +571,6 @@ const char *sql_pool_bytes =
 const char *sql_job_bytes =
    "SELECT SUM(JobBytes) FROM Job WHERE JobId IN (%s)";
 
-
 /* Get Media Ids in Pool */
 const char *sql_mediaids =
    "SELECT MediaId FROM Media,Pool WHERE"
index 0ff4b9c2accedb460a184c2be4822cd0e1ca1f2f..19bc1d4f6e31d5966ded9475bc79dc89cffc3b0d 100644 (file)
@@ -202,7 +202,7 @@ int prune_files(UAContext *ua, CLIENT *client)
    now = (utime_t)time(NULL);
 
    /* Select Jobs -- for counting */
-   Mmsg(query, count_select_job, edit_uint64(now - period, ed1), 
+   Mmsg(query, count_select_job, edit_int64(now - period, ed1), 
         edit_int64(cr.ClientId, ed2));
    Dmsg3(050, "select now=%u period=%u sql=%s\n", (uint32_t)now, 
                (uint32_t)period, query.c_str());
@@ -230,7 +230,7 @@ int prune_files(UAContext *ua, CLIENT *client)
    del.JobId = (JobId_t *)malloc(sizeof(JobId_t) * del.max_ids);
 
    /* Now process same set but making a delete list */
-   Mmsg(query, select_job, edit_uint64(now - period, ed1), 
+   Mmsg(query, select_job, edit_int64(now - period, ed1), 
         edit_int64(cr.ClientId, ed2));
    db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)&del);
 
@@ -318,7 +318,7 @@ int prune_jobs(UAContext *ua, CLIENT *client, int JobType)
     * Select all files that are older than the JobRetention period
     *  and stuff them into the "DeletionCandidates" table.
     */
-   edit_uint64(now - period, ed1);
+   edit_int64(now - period, ed1);
    Mmsg(query, insert_delcand, (char)JobType, ed1, 
         edit_int64(cr.ClientId, ed2));
    if (!db_sql_query(ua->db, query.c_str(), NULL, (void *)NULL)) {
@@ -443,10 +443,10 @@ int get_prune_list_for_volume(UAContext *ua, MEDIA_DBR *mr, del_ctx *del)
    edit_int64(mr->MediaId, ed1); 
    period = mr->VolRetention;
    now = (utime_t)time(NULL);
-   edit_uint64(now-period, ed2);
+   edit_int64(now-period, ed2);
    Mmsg(query, sel_JobMedia, ed1, ed2);
-   Dmsg3(250, "Now=%d period=%d now-period=%d\n", (int)now, (int)period,
-      (int)(now-period));
+   Dmsg3(250, "Now=%d period=%d now-period=%s\n", (int)now, (int)period,
+      ed2);
 
    Dmsg1(050, "Query=%s\n", query.c_str());
    if (!db_sql_query(ua->db, query.c_str(), file_delete_handler, (void *)del)) {
index 2343e93ec03187dd1b0e50204089c174d42c3c83..61a934bf6bb02dec301a26ccd28f3cc574c24907 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "2.4.3"
-#define BDATE   "10 October 2008"
-#define LSMDATE "10Oct08"
+#define BDATE   "24 October 2008"
+#define LSMDATE "24Oct08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index 1e82a143ee1ee2e49914ddef4e1da31d0820998c..3ae66c18f57f2fe47ecf87a95fc9733b476db3af 100644 (file)
@@ -1,6 +1,11 @@
               Technical notes on version 2.4
 
 General:
+24Oct08
+kes  Modify SQL so that jobs that failed will not be migrated.
+kes  Correct bug where long retention periods caused immediate
+     prunning.
+
 Release Version 2.4.3   
 27Oct08
 ebl  Apply 2.4.3-update-slots.patch to fix #1175. About update slots