]> git.sur5r.net Git - bacula/bacula/commitdiff
kes Fix a recycling problem with two autochangers reported in bug
authorKern Sibbald <kern@sibbald.com>
Thu, 26 Jun 2008 08:31:49 +0000 (08:31 +0000)
committerKern Sibbald <kern@sibbald.com>
Thu, 26 Jun 2008 08:31:49 +0000 (08:31 +0000)
     #1106. This may also (unlikely) fix a second recycling bug as
     reported in #1103.
kes  Fix a SD lock volumes deadlock problem reported in bug #1100.

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

bacula/src/dird/autoprune.c
bacula/src/dird/recycle.c
bacula/src/stored/mount.c
bacula/src/version.h
bacula/technotes-2.3

index cc812c5cbba5e2d9f5dfd9737ff02f4ba212e934..df4cb5542db2150b1a15cf77cc5269423a87f35a 100644 (file)
@@ -96,7 +96,7 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
    POOL_MEM query(PM_MESSAGE);
    UAContext *ua;
    bool ok = false;
-   char ed1[50], ed2[100];
+   char ed1[50], ed2[100], ed3[50];
    POOL_DBR spr;
 
    Dmsg1(050, "Prune volumes PoolId=%d\n", jcr->jr.PoolId);
@@ -138,10 +138,18 @@ bool prune_volumes(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
     *  RecyclePoolId is the current pool or the scratch pool
     */
    const char *select = "SELECT DISTINCT MediaId,LastWritten FROM Media WHERE "
-        "(PoolId=%s OR RecyclePoolId IN (%s)) AND MediaType='%s' "
+        "(PoolId=%s OR RecyclePoolId IN (%s)) AND MediaType='%s' %s"
         "ORDER BY LastWritten ASC,MediaId";
 
-   Mmsg(query, select, ed1, ed2, mr->MediaType);
+   if (InChanger) {
+      char changer[100];
+      /* Ensure it is in this autochanger */
+      bsnprintf(changer, sizeof(changer), "AND InChanger=1 AND StorageId=%s ",
+         edit_int64(mr->StorageId, ed3));
+      Mmsg(query, select, ed1, ed2, mr->MediaType, changer);
+   } else {
+      Mmsg(query, select, ed1, ed2, mr->MediaType, "");
+   }
 
    Dmsg1(050, "query=%s\n", query.c_str());
    if (!db_get_query_dbids(ua->jcr, ua->db, query, ids)) {
index fdabb4d6009da41a6ba545ac782c25ae9810b021..d960643db66078a78784ea598c37a4836195434e 100644 (file)
@@ -83,12 +83,19 @@ bool recycle_oldest_purged_volume(JCR *jcr, bool InChanger, MEDIA_DBR *mr)
    const char *select =
           "SELECT MediaId,LastWritten FROM Media "
           "WHERE PoolId=%s AND Recycle=1 AND VolStatus='Purged' "
-          "AND Enabled=1 AND MediaType='%s' "
+          "AND Enabled=1 AND MediaType='%s' %s"
           "ORDER BY LastWritten ASC,MediaId LIMIT 1";
 
    Dmsg0(100, "Enter recycle_oldest_purged_volume\n");
    oldest.MediaId = 0;
-   Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType);
+   if (InChanger) {
+      char changer[100];
+      bsnprintf(changer, sizeof(changer), "AND InChanger=1 AND StorageId=%s ",
+         edit_int64(mr->StorageId, ed1));
+      Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType, changer);
+   } else {
+      Mmsg(query, select, edit_int64(mr->PoolId, ed1), mr->MediaType, "");
+   }
 
    if (!db_sql_query(jcr->db, query, oldest_handler, (void *)&oldest)) {
       Jmsg(jcr, M_ERROR, 0, "%s", db_strerror(jcr->db));
index 26d0cb224f174fb5c22731c9d6e9394280f9cfb2..e4f7cf7ada012f5b9c3887a86a012c98375eee63 100644 (file)
@@ -179,9 +179,13 @@ mount_next_vol:
    }
    Dmsg2(150, "Ask=%d autochanger=%d\n", ask, autochanger);
 
-   if (ask && !dir_ask_sysop_to_mount_volume(dcr, ST_APPEND)) {
-      Dmsg0(150, "Error return ask_sysop ...\n");
-      goto bail_out;          /* error return */
+   if (ask) {
+      unlock_volumes();
+      if (!dir_ask_sysop_to_mount_volume(dcr, ST_APPEND)) {
+         Dmsg0(150, "Error return ask_sysop ...\n");
+         goto no_lock_bail_out;  /* error return */
+      }
+      lock_volumes();
    }
    if (job_canceled(jcr)) {
       goto bail_out;
index 646013a6c17e744cd9f95a3e9dc21627d369fb0a..4d29dc13dc448883126d893e45e53ed61a7a59e0 100644 (file)
@@ -4,8 +4,8 @@
 
 #undef  VERSION
 #define VERSION "2.4.1"
-#define BDATE   "22 June 2008"
-#define LSMDATE "22Jun08"
+#define BDATE   "26 June 2008"
+#define LSMDATE "26Jun08"
 
 #define PROG_COPYRIGHT "Copyright (C) %d-2008 Free Software Foundation Europe e.V.\n"
 #define BYEAR "2008"       /* year for copyright messages in progs */
index f8665542becf8e7cb9ae4e648f623426c71560ba..a379e5efd45e8cd51d043a6b59e493308f96592c 100644 (file)
@@ -1,6 +1,11 @@
               Technical notes on version 2.2
 
 General:
+26Jun08
+kes  Fix a recycling problem with two autochangers reported in bug
+     #1106. This may also (unlikely) fix a second recycling bug as
+     reported in #1103.
+kes  Fix a SD lock volumes deadlock problem reported in bug #1100.
 25Jun08
 kes  Fix format problem in bscan output reported in bug #1105.
 22Jun08