From 55213068a9e36c6fa921606d5ade51d2c16a9257 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Sun, 15 May 2005 19:35:00 +0000 Subject: [PATCH] - Set reconnect flag in MySQL packet to 1 to ensure that connection is re-established. MySQL 5 changed default to 0. Fixes bug report. - Fix Scratch pool handling as reported in a bug by Eric Bollengier by applying his patch. - Remove delete job in favor of delete jobid. - Add = NULL to configfile definitions as reported by Eric in a bug report. - Update winbacula.nsi.in to reflect new manual file structure. git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@2045 91ce42f0-d328-0410-95d8-f526ca767f89 --- bacula/kes-1.37 | 9 ++ bacula/src/cats/mysql.c | 1 + bacula/src/dird/next_vol.c | 219 ++++++++++++++++++----------------- bacula/src/dird/ua_cmds.c | 4 +- bacula/src/stored/bcopy.c | 2 +- bacula/src/stored/bextract.c | 2 +- bacula/src/stored/bls.c | 2 +- bacula/src/stored/bscan.c | 2 +- bacula/src/stored/btape.c | 2 +- bacula/src/stored/stored.c | 2 +- bacula/src/version.h | 4 +- 11 files changed, 130 insertions(+), 119 deletions(-) diff --git a/bacula/kes-1.37 b/bacula/kes-1.37 index 8272bfc779..35fa05366e 100644 --- a/bacula/kes-1.37 +++ b/bacula/kes-1.37 @@ -4,6 +4,15 @@ General: Changes to 1.37.18: +15May05 +- Set reconnect flag in MySQL packet to 1 to ensure that connection + is re-established. MySQL 5 changed default to 0. Fixes bug report. +- Fix Scratch pool handling as reported in a bug by Eric Bollengier + by applying his patch. +- Remove delete job in favor of delete jobid. +- Add = NULL to configfile definitions as reported by Eric in a bug + report. +- Update winbacula.nsi.in to reflect new manual file structure. 10May05 - Correct a minor build problem with wx-console. - Add cancel() to Dir Python scripting. diff --git a/bacula/src/cats/mysql.c b/bacula/src/cats/mysql.c index cf5972fbc7..9b3f375db2 100644 --- a/bacula/src/cats/mysql.c +++ b/bacula/src/cats/mysql.c @@ -138,6 +138,7 @@ db_open_database(JCR *jcr, B_DB *mdb) mysql_server_init(0, NULL, NULL); #endif mysql_init(&(mdb->mysql)); + mdb->mysql.reconnect = 1; /* so connection does not timeout */ Dmsg0(50, "mysql_init done\n"); /* If connection fails, try at 5 sec intervals for 30 seconds. */ for (int retry=0; retry < 6; retry++) { diff --git a/bacula/src/dird/next_vol.c b/bacula/src/dird/next_vol.c index 7db844bbea..2ced309bd7 100644 --- a/bacula/src/dird/next_vol.c +++ b/bacula/src/dird/next_vol.c @@ -51,7 +51,7 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create) Dmsg2(100, "CatReq FindMedia: Id=%d, MediaType=%s\n", (int)mr->PoolId, mr->MediaType); /* * If we are using an Autochanger, restrict Volume - * search to the Autochanger on the first pass + * search to the Autochanger on the first pass */ InChanger = store->autochanger; /* @@ -66,110 +66,113 @@ int find_next_volume_for_append(JCR *jcr, MEDIA_DBR *mr, bool create) ok = db_find_next_volume(jcr, jcr->db, 1, InChanger, mr); Dmsg2(100, "catreq after find_next_vol ok=%d FW=%d\n", ok, mr->FirstWritten); if (!ok) { - /* - * 2. Try finding a recycled volume - */ - ok = find_recycled_volume(jcr, InChanger, mr); + /* + * 2. Try finding a recycled volume + */ + ok = find_recycled_volume(jcr, InChanger, mr); Dmsg2(100, "find_recycled_volume %d FW=%d\n", ok, mr->FirstWritten); - if (!ok) { - /* - * 3. Try recycling any purged volume - */ - ok = recycle_oldest_purged_volume(jcr, InChanger, mr); - if (!ok) { - /* - * 4. Try pruning Volumes - */ - prune_volumes(jcr); - ok = recycle_oldest_purged_volume(jcr, InChanger, mr); - if (InChanger) { - InChanger = false; - if (!ok) { - continue; /* retry again accepting any volume */ - } - } + if (!ok) { + /* + * 3. Try recycling any purged volume + */ + ok = recycle_oldest_purged_volume(jcr, InChanger, mr); + if (!ok) { + /* + * 4. Try pruning Volumes + */ + prune_volumes(jcr); + ok = recycle_oldest_purged_volume(jcr, InChanger, mr); + if (InChanger) { + InChanger = false; + if (!ok) { + continue; /* retry again accepting any volume */ + } + } Dmsg2(200, "find_recycled_volume2 %d FW=%d\n", ok, mr->FirstWritten); - if (!ok && create) { - /* + if (!ok && create) { + /* * 5. Try "creating" a new Volume - */ - ok = newVolume(jcr, mr); - } - } - } + */ + ok = newVolume(jcr, mr); + } + } + } - if (!ok) { - MEDIA_DBR smr; - POOL_DBR pr; - POOLMEM *query; - char ed1[50], ed2[50]; - /* - * 6. Try pulling a volume from the Scratch pool - */ - memset(&pr, 0, sizeof(pr)); + if (!ok) { + MEDIA_DBR smr; + POOL_DBR pr; + POOLMEM *query; + char ed1[50], ed2[50]; + /* + * 6. Try pulling a volume from the Scratch pool + */ + memset(&pr, 0, sizeof(pr)); bstrncpy(pr.Name, "Scratch", sizeof(pr.Name)); - if (db_get_pool_record(jcr, jcr->db, &pr)) { - memset(&smr, 0, sizeof(smr)); - smr.PoolId = pr.PoolId; + if (db_get_pool_record(jcr, jcr->db, &pr)) { + memset(&smr, 0, sizeof(smr)); + smr.PoolId = pr.PoolId; bstrncpy(smr.VolStatus, "Append", sizeof(smr.VolStatus)); /* want only appendable volumes */ - bstrncpy(smr.MediaType, mr->MediaType, sizeof(smr.MediaType)); - if (db_find_next_volume(jcr, jcr->db, 1, InChanger, &smr)) { - query = get_pool_memory(PM_MESSAGE); - db_lock(jcr->db); + bstrncpy(smr.MediaType, mr->MediaType, sizeof(smr.MediaType)); + if (db_find_next_volume(jcr, jcr->db, 1, InChanger, &smr)) { + query = get_pool_memory(PM_MESSAGE); + db_lock(jcr->db); Mmsg(query, "UPDATE Media SET PoolId=%s WHERE MediaId=%s", - edit_int64(mr->PoolId, ed1), - edit_int64(mr->MediaId, ed2)); - ok = db_sql_query(jcr->db, query, NULL, NULL); - db_unlock(jcr->db); - } - } - } - /* - * Look at more drastic ways to find an Appendable Volume - */ - if (!ok && (jcr->pool->purge_oldest_volume || - jcr->pool->recycle_oldest_volume)) { + edit_int64(mr->PoolId, ed1), + edit_int64(smr.MediaId, ed2)); + ok = db_sql_query(jcr->db, query, NULL, NULL); + db_unlock(jcr->db); + /* Set new Pool Id in smr record, then copy it to mr */ + smr.PoolId = mr->PoolId; + memcpy(mr, &smr, sizeof(MEDIA_DBR)); + } + } + } + /* + * Look at more drastic ways to find an Appendable Volume + */ + if (!ok && (jcr->pool->purge_oldest_volume || + jcr->pool->recycle_oldest_volume)) { Dmsg2(200, "No next volume found. PurgeOldest=%d\n RecyleOldest=%d", - jcr->pool->purge_oldest_volume, jcr->pool->recycle_oldest_volume); - /* Find oldest volume to recycle */ - ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr); + jcr->pool->purge_oldest_volume, jcr->pool->recycle_oldest_volume); + /* Find oldest volume to recycle */ + ok = db_find_next_volume(jcr, jcr->db, -1, InChanger, mr); Dmsg1(400, "Find oldest=%d\n", ok); - if (ok) { - UAContext *ua; + if (ok) { + UAContext *ua; Dmsg0(400, "Try purge.\n"); - /* - * 5. Try to purging oldest volume only if not UA calling us. - */ - ua = new_ua_context(jcr); - if (jcr->pool->purge_oldest_volume && create) { + /* + * 5. Try to purging oldest volume only if not UA calling us. + */ + ua = new_ua_context(jcr); + if (jcr->pool->purge_oldest_volume && create) { Jmsg(jcr, M_INFO, 0, _("Purging oldest volume \"%s\"\n"), mr->VolumeName); - ok = purge_jobs_from_volume(ua, mr); - /* - * 5. or try recycling the oldest volume - */ - } else if (jcr->pool->recycle_oldest_volume) { + ok = purge_jobs_from_volume(ua, mr); + /* + * 5. or try recycling the oldest volume + */ + } else if (jcr->pool->recycle_oldest_volume) { Jmsg(jcr, M_INFO, 0, _("Pruning oldest volume \"%s\"\n"), mr->VolumeName); - ok = prune_volume(ua, mr); - } - free_ua_context(ua); - if (ok) { - ok = recycle_volume(jcr, mr); + ok = prune_volume(ua, mr); + } + free_ua_context(ua); + if (ok) { + ok = recycle_volume(jcr, mr); Dmsg1(400, "Recycle after purge oldest=%d\n", ok); - } - } - } + } + } + } } Dmsg2(100, "VolJobs=%d FirstWritten=%d\n", mr->VolJobs, mr->FirstWritten); if (ok) { - /* If we can use the volume, check if it is expired */ - if (has_volume_expired(jcr, mr)) { - if (retry++ < 200) { /* sanity check */ - continue; /* try again from the top */ - } else { - Jmsg(jcr, M_ERROR, 0, _( + /* If we can use the volume, check if it is expired */ + if (has_volume_expired(jcr, mr)) { + if (retry++ < 200) { /* sanity check */ + continue; /* try again from the top */ + } else { + Jmsg(jcr, M_ERROR, 0, _( "We seem to be looping trying to find the next volume. I give up.\n")); - } - } + } + } } break; } /* end for loop */ @@ -195,46 +198,46 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr) Jmsg(jcr, M_INFO, 0, _("Max Volume bytes exceeded. " "Marking Volume \"%s\" as Full.\n"), mr->VolumeName); bstrncpy(mr->VolStatus, "Full", sizeof(mr->VolStatus)); - expired = true; + expired = true; /* Now see if Volume should only be used once */ } else if (mr->VolBytes > 0 && jcr->pool->use_volume_once) { Jmsg(jcr, M_INFO, 0, _("Volume used once. " "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); - expired = true; + expired = true; /* Now see if Max Jobs written to volume */ } else if (mr->MaxVolJobs > 0 && mr->MaxVolJobs <= mr->VolJobs) { Jmsg(jcr, M_INFO, 0, _("Max Volume jobs exceeded. " "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); - expired = true; + expired = true; /* Now see if Max Files written to volume */ } else if (mr->MaxVolFiles > 0 && mr->MaxVolFiles <= mr->VolFiles) { Jmsg(jcr, M_INFO, 0, _("Max Volume files exceeded. " "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); - expired = true; + expired = true; /* Finally, check Use duration expiration */ } else if (mr->VolUseDuration > 0) { - utime_t now = time(NULL); - /* See if Vol Use has expired */ - if (mr->VolUseDuration <= (now - mr->FirstWritten)) { + utime_t now = time(NULL); + /* See if Vol Use has expired */ + if (mr->VolUseDuration <= (now - mr->FirstWritten)) { Jmsg(jcr, M_INFO, 0, _("Max configured use duration exceeded. " "Marking Volume \"%s\" as Used.\n"), mr->VolumeName); bstrncpy(mr->VolStatus, "Used", sizeof(mr->VolStatus)); - expired = true; - } + expired = true; + } } } if (expired) { /* Need to update media */ if (!db_update_media_record(jcr, jcr->db, mr)) { Jmsg(jcr, M_ERROR, 0, _("Catalog error updating volume \"%s\". ERR=%s"), - mr->VolumeName, db_strerror(jcr->db)); + mr->VolumeName, db_strerror(jcr->db)); } } return expired; @@ -244,7 +247,7 @@ bool has_volume_expired(JCR *jcr, MEDIA_DBR *mr) * Try hard to recycle the current volume * * Returns: on failure - reason = NULL - * on success - reason - pointer to reason + * on success - reason - pointer to reason */ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **reason) { @@ -273,12 +276,12 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r if (strcmp(mr->VolStatus, "Purged") == 0) { if (recycle_volume(jcr, mr)) { Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName); - *reason = NULL; - return; + *reason = NULL; + return; } else { /* In principle this shouldn't happen */ *reason = "and recycling of current volume failed"; - return; + return; } } @@ -292,7 +295,7 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r * needed for? */ if ((mr->LastWritten + mr->VolRetention) < (utime_t)time(NULL) - && mr->Recycle && jcr->pool->recycle_current_volume + && mr->Recycle && jcr->pool->recycle_current_volume && (strcmp(mr->VolStatus, "Full") == 0 || strcmp(mr->VolStatus, "Used") == 0)) { /* @@ -306,14 +309,14 @@ void check_if_volume_valid_or_recyclable(JCR *jcr, MEDIA_DBR *mr, const char **r free_ua_context(ua); if (ok) { - /* If fully purged, recycle current volume */ - if (recycle_volume(jcr, mr)) { + /* If fully purged, recycle current volume */ + if (recycle_volume(jcr, mr)) { Jmsg(jcr, M_INFO, 0, "Recycled current volume \"%s\"\n", mr->VolumeName); - *reason = NULL; - } else { + *reason = NULL; + } else { *reason = "but should be Append, Purged or Recycle (recycling of the " "current volume failed)"; - } + } } else { *reason = "but should be Append, Purged or Recycle (cannot automatically " "recycle current volume, as it still contains unpruned data)"; diff --git a/bacula/src/dird/ua_cmds.c b/bacula/src/dird/ua_cmds.c index 1cfceb494f..001caca19a 100644 --- a/bacula/src/dird/ua_cmds.c +++ b/bacula/src/dird/ua_cmds.c @@ -1054,14 +1054,13 @@ static int reload_cmd(UAContext *ua, const char *cmd) * * delete pool= * delete volume pool= volume= - * delete job jobid=xxx + * delete jobid=xxx */ static int delete_cmd(UAContext *ua, const char *cmd) { static const char *keywords[] = { N_("volume"), N_("pool"), - N_("job"), N_("jobid"), NULL}; @@ -1077,7 +1076,6 @@ static int delete_cmd(UAContext *ua, const char *cmd) delete_pool(ua); return 1; case 2: - case 3: int i; while ((i=find_arg(ua, _("jobid"))) > 0) { delete_job(ua); diff --git a/bacula/src/stored/bcopy.c b/bacula/src/stored/bcopy.c index 3ceafca90b..4fb6ad1662 100644 --- a/bacula/src/stored/bcopy.c +++ b/bacula/src/stored/bcopy.c @@ -50,7 +50,7 @@ static uint32_t jobs = 0; static DEV_BLOCK *out_block; #define CONFIG_FILE "bacula-sd.conf" -char *configfile; +char *configfile = NULL; STORES *me = NULL; /* our Global resource */ bool forge_on = false; /* proceed inspite of I/O errors */ pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/bacula/src/stored/bextract.c b/bacula/src/stored/bextract.c index 99a9438bd7..8dab7ee710 100644 --- a/bacula/src/stored/bextract.c +++ b/bacula/src/stored/bextract.c @@ -63,7 +63,7 @@ static uint32_t wsize; /* write size */ static uint64_t fileAddr = 0; /* file write address */ #define CONFIG_FILE "bacula-sd.conf" -char *configfile; +char *configfile = NULL; STORES *me = NULL; /* our Global resource */ bool forge_on = false; pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/bacula/src/stored/bls.c b/bacula/src/stored/bls.c index 1a9a1448bd..dbf0e0ff9d 100644 --- a/bacula/src/stored/bls.c +++ b/bacula/src/stored/bls.c @@ -57,7 +57,7 @@ static uint32_t num_files = 0; static ATTR *attr; #define CONFIG_FILE "bacula-sd.conf" -char *configfile; +char *configfile = NULL; STORES *me = NULL; /* our Global resource */ bool forge_on = false; pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/bacula/src/stored/bscan.c b/bacula/src/stored/bscan.c index 8cc93f69ac..d367b99a3e 100644 --- a/bacula/src/stored/bscan.c +++ b/bacula/src/stored/bscan.c @@ -101,7 +101,7 @@ static int num_media = 0; static int num_files = 0; #define CONFIG_FILE "bacula-sd.conf" -char *configfile; +char *configfile = NULL; STORES *me = NULL; /* our Global resource */ bool forge_on = false; /* proceed inspite of I/O errors */ pthread_mutex_t device_release_mutex = PTHREAD_MUTEX_INITIALIZER; diff --git a/bacula/src/stored/btape.c b/bacula/src/stored/btape.c index 86f58b75b6..4c023b36df 100644 --- a/bacula/src/stored/btape.c +++ b/bacula/src/stored/btape.c @@ -91,7 +91,7 @@ static void do_unfill(); /* Static variables */ #define CONFIG_FILE "bacula-sd.conf" -char *configfile; +char *configfile = NULL; #define MAX_CMD_ARGS 30 static POOLMEM *cmd; diff --git a/bacula/src/stored/stored.c b/bacula/src/stored/stored.c index 5d6d3e0b34..50bb025aa1 100644 --- a/bacula/src/stored/stored.c +++ b/bacula/src/stored/stored.c @@ -54,7 +54,7 @@ pthread_cond_t wait_device_release = PTHREAD_COND_INITIALIZER; static uint32_t VolSessionId = 0; uint32_t VolSessionTime; -char *configfile; +char *configfile = NULL; /* Global static variables */ static int foreground = 0; diff --git a/bacula/src/version.h b/bacula/src/version.h index 97d8003e37..9dc7ed5466 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -1,8 +1,8 @@ /* */ #undef VERSION #define VERSION "1.37.18" -#define BDATE "10 May 2005" -#define LSMDATE "10May05" +#define BDATE "15 May 2005" +#define LSMDATE "15May05" /* Debug flags */ #undef DEBUG -- 2.39.5