From: Kern Sibbald Date: Tue, 28 Oct 2008 19:51:46 +0000 (+0000) Subject: kes Modify SQL so that jobs that failed will not be migrated. X-Git-Tag: Release-2.4.4~50 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=006a9447c6e8d86c9cbf4bf188281aa7edd887a9;p=bacula%2Fbacula kes Modify SQL so that jobs that failed will not be migrated. 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 --- diff --git a/bacula/patches/2.4.3-migrate.patch b/bacula/patches/2.4.3-migrate.patch new file mode 100644 index 0000000000..138c09c9d1 --- /dev/null +++ b/bacula/patches/2.4.3-migrate.patch @@ -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 + patch -p0 <2.4.3-migrate.patch + ./configure + 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 index 0000000000..7af00a7bec --- /dev/null +++ b/bacula/patches/2.4.3-prune.patch @@ -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 + patch -p0 <2.4.3-prune.patch + ./configure + 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)) { diff --git a/bacula/src/dird/migrate.c b/bacula/src/dird/migrate.c index 0327b018ff..5776f2364e 100644 --- a/bacula/src/dird/migrate.c +++ b/bacula/src/dird/migrate.c @@ -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" diff --git a/bacula/src/dird/ua_prune.c b/bacula/src/dird/ua_prune.c index 0ff4b9c2ac..19bc1d4f6e 100644 --- a/bacula/src/dird/ua_prune.c +++ b/bacula/src/dird/ua_prune.c @@ -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)) { diff --git a/bacula/src/version.h b/bacula/src/version.h index 2343e93ec0..61a934bf6b 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 */ diff --git a/bacula/technotes-2.4 b/bacula/technotes-2.4 index 1e82a143ee..3ae66c18f5 100644 --- a/bacula/technotes-2.4 +++ b/bacula/technotes-2.4 @@ -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