diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index b0ede922453ca3e007727064ab5ced0f5ae8e8be..6aee3a9f631e8e88653d16e27dd2f7afd46cfc22 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -2339,6 +2339,32 @@ void RdbmsCatalogue::setTapeFull(const common::dataStructures::SecurityIdentity // noSpaceLeftOnTape //------------------------------------------------------------------------------ void RdbmsCatalogue::noSpaceLeftOnTape(const std::string &vid) { + const uint32_t maxTries = 3; + + for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { + try { + return noSpaceLeftOnTapeInternal(vid); + } catch(exception::LostDatabaseConnection &lc) { + // Ignore lost connection + std::list<log::Param> params = { + {"maxTries", maxTries}, + {"tryNb", tryNb}, + {"msg", lc.getMessage()} + }; + m_log(cta::log::WARNING, "Lost database connection", params); + } + } + + exception::Exception ex; + ex.getMessage() << std::string(__FUNCTION__) << " failed: Lost the database connection after trying " << maxTries << + " times"; + throw ex; +} + +//------------------------------------------------------------------------------ +// noSpaceLeftOnTapeInternal +//------------------------------------------------------------------------------ +void RdbmsCatalogue::noSpaceLeftOnTapeInternal(const std::string &vid) { try { const char *const sql = "UPDATE TAPE SET " @@ -2350,9 +2376,11 @@ void RdbmsCatalogue::noSpaceLeftOnTape(const std::string &vid) { stmt.bindString(":VID", vid); stmt.executeNonQuery(); - if(0 == stmt.getNbAffectedRows()) { + if (0 == stmt.getNbAffectedRows()) { throw exception::Exception(std::string("Tape ") + vid + " does not exist"); } + } catch (exception::LostDatabaseConnection &) { + throw; } catch (exception::Exception &ex) { throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); } diff --git a/catalogue/RdbmsCatalogue.hpp b/catalogue/RdbmsCatalogue.hpp index 391cdea5e74319f2cbbfb4331d778b64ff5d74f2..69747edf45f20edbe13086b9226ae9fdd18b81a3 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -1035,6 +1035,14 @@ protected: */ void tapeMountedForRetrieveInternal(const std::string &vid, const std::string &drive); + /** + * This method notifies the CTA catalogue that there is no more free space on + * the specified tape. + * + * @param vid The volume identifier of the tape. + */ + void noSpaceLeftOnTapeInternal(const std::string &vid); + /** * Prepares the catalogue for a new archive file and returns the information * required to queue the associated archive request.