From 90e7fd88407d2338df0c642c402e8145139e26d0 Mon Sep 17 00:00:00 2001 From: Steven Murray <Steven.Murray@cern.ch> Date: Tue, 30 Jan 2018 16:02:54 +0100 Subject: [PATCH] cta/CTA#186 CTA should cope with idle database connections being dropped by the database server Refactored retryOnLostConnection() from OracleCatalogue and RdbmsCatalogue --- catalogue/OracleCatalogue.cpp | 37 +---- catalogue/OracleCatalogue.hpp | 6 +- catalogue/RdbmsCatalogue.cpp | 247 +++++----------------------- catalogue/RdbmsCatalogue.hpp | 12 +- catalogue/retryOnLostConnection.hpp | 74 +++++++++ 5 files changed, 141 insertions(+), 235 deletions(-) create mode 100644 catalogue/retryOnLostConnection.hpp diff --git a/catalogue/OracleCatalogue.cpp b/catalogue/OracleCatalogue.cpp index 05fbb26d3a..d91c04cd4e 100644 --- a/catalogue/OracleCatalogue.cpp +++ b/catalogue/OracleCatalogue.cpp @@ -18,6 +18,7 @@ #include "catalogue/ArchiveFileRow.hpp" #include "catalogue/OracleCatalogue.hpp" +#include "catalogue/retryOnLostConnection.hpp" #include "common/exception/Exception.hpp" #include "common/exception/LostDatabaseConnection.hpp" #include "common/exception/UserError.hpp" @@ -119,13 +120,14 @@ OracleCatalogue::OracleCatalogue( const std::string &password, const std::string &database, const uint64_t nbConns, - const uint64_t nbArchiveFileListingConns): + const uint64_t nbArchiveFileListingConns, + const uint32_t maxTriesToConnect): RdbmsCatalogue( log, rdbms::Login(rdbms::Login::DBTYPE_ORACLE, username, password, database), nbConns, - nbArchiveFileListingConns) { - + nbArchiveFileListingConns, + maxTriesToConnect) { } //------------------------------------------------------------------------------ @@ -592,30 +594,7 @@ common::dataStructures::Tape OracleCatalogue::selectTapeForUpdate(rdbms::Conn &c // filesWrittenToTape //------------------------------------------------------------------------------ void OracleCatalogue::filesWrittenToTape(const std::set<TapeFileWritten> &events) { - try { - const uint32_t maxTries = 3; - for (uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return filesWrittenToTapeInternal(events); - } 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() << "Lost the database connection after trying " << maxTries << " times"; - throw ex; - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } catch(std::exception &se) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + se.what()); - } + return retryOnLostConnection(m_log, [&]{return filesWrittenToTapeInternal(events);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -723,8 +702,8 @@ void OracleCatalogue::filesWrittenToTapeInternal(const std::set<TapeFileWritten> conn.commit(); - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); } catch(exception::Exception &ex) { throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); } catch(std::exception &se) { diff --git a/catalogue/OracleCatalogue.hpp b/catalogue/OracleCatalogue.hpp index 77a921c560..56ea0ebe79 100644 --- a/catalogue/OracleCatalogue.hpp +++ b/catalogue/OracleCatalogue.hpp @@ -43,6 +43,9 @@ public: * @param nbArchiveFileListingConns The maximum number of concurrent * connections to the underlying relational database for the sole purpose of * listing archive files. + * @param maxTriesToConnext The maximum number of times a single method should + * try to connect to the database in the event of LostDatabaseConnection + * exceptions being thrown. */ OracleCatalogue( log::Logger &log, @@ -50,7 +53,8 @@ public: const std::string &password, const std::string &database, const uint64_t nbConns, - const uint64_t nbArchiveFileListingConns); + const uint64_t nbArchiveFileListingConns, + const uint32_t maxTriesToConnect = 3); /** * Destructor. diff --git a/catalogue/RdbmsCatalogue.cpp b/catalogue/RdbmsCatalogue.cpp index af96e83fd2..2e4f3b6131 100644 --- a/catalogue/RdbmsCatalogue.cpp +++ b/catalogue/RdbmsCatalogue.cpp @@ -19,6 +19,7 @@ #include "catalogue/ArchiveFileRow.hpp" #include "catalogue/RdbmsArchiveFileItorImpl.hpp" #include "catalogue/RdbmsCatalogue.hpp" +#include "catalogue/retryOnLostConnection.hpp" #include "catalogue/SqliteCatalogueSchema.hpp" #include "common/dataStructures/TapeFile.hpp" #include "common/exception/Exception.hpp" @@ -44,10 +45,12 @@ RdbmsCatalogue::RdbmsCatalogue( log::Logger &log, const rdbms::Login &login, const uint64_t nbConns, - const uint64_t nbArchiveFileListingConns): + const uint64_t nbArchiveFileListingConns, + const uint32_t maxTriesToConnect): Catalogue(log), m_connPool(login, nbConns), - m_archiveFileListingConnPool(login, nbArchiveFileListingConns) { + m_archiveFileListingConnPool(login, nbArchiveFileListingConns), + m_maxTriesToConnect(maxTriesToConnect) { } //------------------------------------------------------------------------------ @@ -2191,26 +2194,7 @@ void RdbmsCatalogue::modifyTapeEncryptionKey(const common::dataStructures::Secur // tapeMountedForArchive //------------------------------------------------------------------------------ void RdbmsCatalogue::tapeMountedForArchive(const std::string &vid, const std::string &drive) { - const uint32_t maxTries = 3; - - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return tapeMountedForArchiveInternal(vid, drive); - } 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; + return retryOnLostConnection(m_log, [&]{return tapeMountedForArchiveInternal(vid, drive);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -2235,8 +2219,8 @@ void RdbmsCatalogue::tapeMountedForArchiveInternal(const std::string &vid, const if (0 == stmt.getNbAffectedRows()) { throw exception::UserError(std::string("Cannot modify tape ") + vid + " because it does not exist"); } - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + "failed: " + le.getMessage().str()); } catch(exception::UserError &) { throw; } catch (exception::Exception &ex) { @@ -2248,26 +2232,7 @@ void RdbmsCatalogue::tapeMountedForArchiveInternal(const std::string &vid, const // tapeMountedForRetrieve //------------------------------------------------------------------------------ void RdbmsCatalogue::tapeMountedForRetrieve(const std::string &vid, const std::string &drive) { - const uint32_t maxTries = 3; - - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return tapeMountedForRetrieveInternal(vid, drive); - } 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; + return retryOnLostConnection(m_log, [&]{return tapeMountedForRetrieveInternal(vid, drive);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -2292,8 +2257,8 @@ void RdbmsCatalogue::tapeMountedForRetrieveInternal(const std::string &vid, cons if(0 == stmt.getNbAffectedRows()) { throw exception::UserError(std::string("Cannot modify tape ") + vid + " because it does not exist"); } - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + "failed: " + le.getMessage().str()); } catch(exception::UserError &) { throw; } catch (exception::Exception &ex) { @@ -2339,26 +2304,7 @@ 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; + return retryOnLostConnection(m_log, [&]{return noSpaceLeftOnTapeInternal(vid);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -2379,8 +2325,8 @@ void RdbmsCatalogue::noSpaceLeftOnTapeInternal(const std::string &vid) { if (0 == stmt.getNbAffectedRows()) { throw exception::Exception(std::string("Tape ") + vid + " does not exist"); } - } catch (exception::LostDatabaseConnection &) { - throw; + } catch (exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); } catch (exception::Exception &ex) { throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); } @@ -3832,26 +3778,7 @@ common::dataStructures::ArchiveFile RdbmsCatalogue::getArchiveFileById(const uin // tapeLabelled //------------------------------------------------------------------------------ void RdbmsCatalogue::tapeLabelled(const std::string &vid, const std::string &drive, const bool lbpIsOn) { - const uint32_t maxTries = 3; - - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return tapeLabelledInternal(vid, drive, lbpIsOn); - } 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; + return retryOnLostConnection(m_log, [&]{return tapeLabelledInternal(vid, drive, lbpIsOn);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -3878,8 +3805,8 @@ void RdbmsCatalogue::tapeLabelledInternal(const std::string &vid, const std::str if(0 == stmt.getNbAffectedRows()) { throw exception::UserError(std::string("Cannot modify tape ") + vid + " because it does not exist"); } - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); } catch(exception::UserError &) { throw; } catch (exception::Exception &ex) { @@ -3892,26 +3819,8 @@ void RdbmsCatalogue::tapeLabelledInternal(const std::string &vid, const std::str //------------------------------------------------------------------------------ common::dataStructures::ArchiveFileQueueCriteria RdbmsCatalogue::prepareForNewFile(const std::string &diskInstanceName, const std::string &storageClassName, const common::dataStructures::UserIdentity &user) { - const uint32_t maxTries = 3; - - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return prepareForNewFileInternal(diskInstanceName, storageClassName, user); - } 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; + return retryOnLostConnection( m_log, [&]{return prepareForNewFileInternal(diskInstanceName, storageClassName, user);}, + m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -3961,8 +3870,8 @@ common::dataStructures::ArchiveFileQueueCriteria RdbmsCatalogue::prepareForNewFi const uint64_t archiveFileId = getNextArchiveFileId(conn); return common::dataStructures::ArchiveFileQueueCriteria(archiveFileId, copyToPoolMap, mountPolicy); - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); } catch(exception::UserError &) { throw; } catch(exception::Exception &ex) { @@ -4069,26 +3978,8 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri const uint64_t archiveFileId, const common::dataStructures::UserIdentity &user, log::LogContext &lc) { - const uint32_t maxTries = 3; - - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return prepareToRetrieveFileInternal(diskInstanceName, archiveFileId, user, lc); - } catch(exception::LostDatabaseConnection &lce) { - // Ignore lost connection - std::list<log::Param> params = { - {"maxTries", maxTries}, - {"tryNb", tryNb}, - {"msg", lce.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; + return retryOnLostConnection( m_log, [&]{return prepareToRetrieveFileInternal(diskInstanceName, archiveFileId, user, + lc);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -4148,8 +4039,8 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri criteria.archiveFile = *archiveFile; criteria.mountPolicy = mountPolicy; return criteria; - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); } catch(exception::UserError &) { throw; } catch(exception::Exception &ex) { @@ -4165,26 +4056,8 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri const std::string &diskFileId, const common::dataStructures::UserIdentity &user, log::LogContext &lc) { - const uint32_t maxTries = 3; - - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return prepareToRetrieveFileByDiskFileIdInternal(diskInstanceName, diskFileId, user, lc); - } catch(exception::LostDatabaseConnection &lce) { - // Ignore lost connection - std::list<log::Param> params = { - {"maxTries", maxTries}, - {"tryNb", tryNb}, - {"msg", lce.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; + return retryOnLostConnection( m_log, [&]{return prepareToRetrieveFileByDiskFileIdInternal(diskInstanceName, + diskFileId, user, lc);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -4238,8 +4111,8 @@ common::dataStructures::RetrieveFileQueueCriteria RdbmsCatalogue::prepareToRetri criteria.archiveFile = *archiveFile; criteria.mountPolicy = mountPolicy; return criteria; - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); } catch(exception::UserError &) { throw; } catch(exception::Exception &ex) { @@ -4353,34 +4226,23 @@ RequesterAndGroupMountPolicies RdbmsCatalogue::getMountPolicies( // isAdmin //------------------------------------------------------------------------------ bool RdbmsCatalogue::isAdmin(const common::dataStructures::SecurityIdentity &admin) const { - const uint32_t maxTries = 3; - - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return isAdminInternal(admin); - } 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; + return retryOnLostConnection(m_log, [&]{return isAdminInternal(admin);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ // isAdminInternal //------------------------------------------------------------------------------ bool RdbmsCatalogue::isAdminInternal(const common::dataStructures::SecurityIdentity &admin) const { - auto conn = m_connPool.getConn(); - return userIsAdmin(conn, admin.username) && hostIsAdmin(conn, admin.host); + try { + auto conn = m_connPool.getConn(); + return userIsAdmin(conn, admin.username) && hostIsAdmin(conn, admin.host); + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); + } catch(exception::UserError &) { + throw; + } catch(exception::Exception &ex) { + throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); + } } //------------------------------------------------------------------------------ @@ -4421,30 +4283,7 @@ bool RdbmsCatalogue::hostIsAdmin(rdbms::Conn &conn, const std::string &hostName) // getTapesForWriting //------------------------------------------------------------------------------ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWriting(const std::string &logicalLibraryName) const { - try { - const uint32_t maxTries = 3; - for(uint32_t tryNb = 1; tryNb <= maxTries; tryNb++) { - try { - return getTapesForWritingInternal(logicalLibraryName); - } 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() << "Lost the database connection after trying " << maxTries << - " times"; - throw ex; - - } catch(exception::Exception &ex) { - throw exception::Exception(std::string(__FUNCTION__) + " failed: " + ex.getMessage().str()); - } + return retryOnLostConnection(m_log, [&]{return getTapesForWritingInternal(logicalLibraryName);}, m_maxTriesToConnect); } //------------------------------------------------------------------------------ @@ -4485,8 +4324,8 @@ std::list<TapeForWriting> RdbmsCatalogue::getTapesForWritingInternal(const std:: tapes.push_back(tape); } return tapes; - } catch(exception::LostDatabaseConnection &) { - throw; + } catch(exception::LostDatabaseConnection &le) { + throw exception::LostDatabaseConnection(std::string(__FUNCTION__) + " failed: " + le.getMessage().str()); } 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 a99fdc6257..de265fc19b 100644 --- a/catalogue/RdbmsCatalogue.hpp +++ b/catalogue/RdbmsCatalogue.hpp @@ -70,12 +70,16 @@ protected: * @param nbArchiveFileListingConns The maximum number of concurrent * connections to the underlying relational database for the sole purpose of * listing archive files. + * @param maxTriesToConnext The maximum number of times a single method should + * try to connect to the database in the event of LostDatabaseConnection + * exceptions being thrown. */ RdbmsCatalogue( log::Logger &log, const rdbms::Login &login, const uint64_t nbConns, - const uint64_t nbArchiveFileListingConns); + const uint64_t nbArchiveFileListingConns, + const uint32_t maxTriesToConnect = 3); public: @@ -548,6 +552,12 @@ protected: */ mutable rdbms::ConnPool m_archiveFileListingConnPool; + /** + * The maximum number of times a single method should try to connect to the + * database in the event of LostDatabaseConnection exceptions being thrown. + */ + uint32_t m_maxTriesToConnect; + /** * Returns true if the specified admin user exists. * diff --git a/catalogue/retryOnLostConnection.hpp b/catalogue/retryOnLostConnection.hpp new file mode 100644 index 0000000000..d3be729260 --- /dev/null +++ b/catalogue/retryOnLostConnection.hpp @@ -0,0 +1,74 @@ +/* + * The CERN Tape Archive(CTA) project + * Copyright(C) 2015 CERN + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + *(at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#pragma once + +#include "common/exception/Exception.hpp" +#include "common/exception/LostDatabaseConnection.hpp" +#include "common/log/Logger.hpp" + +#include <list> +#include <stdint.h> +#include <type_traits> + +namespace cta { +namespace catalogue { + +/** + * Retries calling the specified callable if it throws a LostDatabaseConnection + * exception. + * + * @tparam T The type of the callable. + * @param log Object representing the API to the CTA logging system. + * @param callable The callable. + * @param maxTriesToConnect The maximum number of times the callable should be called in the event of a + * LostDatbaseConnection exception. + * @return The result of calling the callable. + */ +template<typename T> +typename std::result_of<T()>::type retryOnLostConnection(log::Logger &log, const T &callable, + const uint32_t maxTriesToConnect) { + try { + for (uint32_t tryNb = 1; tryNb <= maxTriesToConnect; tryNb++) { + try { + return callable(); + } catch (exception::LostDatabaseConnection &le) { + // Log lost connection + std::list<log::Param> params = { + {"maxTriesToConnect", maxTriesToConnect}, + {"tryNb", tryNb}, + {"msg", le.getMessage()} + }; + log(cta::log::WARNING, "Lost database connection", params); + } + } + + exception::Exception ex; + ex.getMessage() << "Lost the database connection after trying " << maxTriesToConnect << " times"; + throw ex; + } catch (exception::UserError &) { + throw; + } catch (exception::Exception &) { + throw; + } catch (std::exception &se) { + throw exception::Exception(se.what()); + } +} + +} // namespace catalogue +} // namespace cta -- GitLab