From f217e5807f2930fc8a0e3f6b0abe975cec419b90 Mon Sep 17 00:00:00 2001 From: Kern Sibbald Date: Thu, 26 Jun 2008 08:31:49 +0000 Subject: [PATCH] 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. 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 | 14 +++++++++++--- bacula/src/dird/recycle.c | 11 +++++++++-- bacula/src/stored/mount.c | 10 +++++++--- bacula/src/version.h | 4 ++-- bacula/technotes-2.3 | 5 +++++ 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/bacula/src/dird/autoprune.c b/bacula/src/dird/autoprune.c index cc812c5cbb..df4cb5542d 100644 --- a/bacula/src/dird/autoprune.c +++ b/bacula/src/dird/autoprune.c @@ -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)) { diff --git a/bacula/src/dird/recycle.c b/bacula/src/dird/recycle.c index fdabb4d600..d960643db6 100644 --- a/bacula/src/dird/recycle.c +++ b/bacula/src/dird/recycle.c @@ -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)); diff --git a/bacula/src/stored/mount.c b/bacula/src/stored/mount.c index 26d0cb224f..e4f7cf7ada 100644 --- a/bacula/src/stored/mount.c +++ b/bacula/src/stored/mount.c @@ -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; diff --git a/bacula/src/version.h b/bacula/src/version.h index 646013a6c1..4d29dc13dc 100644 --- a/bacula/src/version.h +++ b/bacula/src/version.h @@ -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 */ diff --git a/bacula/technotes-2.3 b/bacula/technotes-2.3 index f8665542be..a379e5efd4 100644 --- a/bacula/technotes-2.3 +++ b/bacula/technotes-2.3 @@ -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 -- 2.39.2