Commit e8c3de80 authored by Eric Cano's avatar Eric Cano
Browse files

Added logging of errors in BackendPopulator::~BackendPopulator().

parent 4ee57747
......@@ -26,7 +26,8 @@ namespace cta { namespace objectstore {
// Constructor
//------------------------------------------------------------------------------
BackendPopulator::BackendPopulator(cta::objectstore::Backend & be,
const std::string &agentType): m_backend(be), m_agentReference(agentType) {
const std::string &agentType, const cta::log::LogContext & lc): m_backend(be), m_agentReference(agentType),
m_lc(lc) {
cta::objectstore::RootEntry re(m_backend);
cta::objectstore::ScopedExclusiveLock rel(re);
re.fetch();
......@@ -52,9 +53,16 @@ BackendPopulator::~BackendPopulator() throw() {
agent.fetch();
agent.removeAndUnregisterSelf();
} catch (cta::exception::Exception & ex) {
cta::log::ScopedParamContainer params(m_lc);
params.add("errorMessage", ex.getMessageValue());
m_lc.log(log::CRIT, "In BackendPopulator::~BackendPopulator(): error deleting agent (cta::exception::Exception). Backtrace follows.");
m_lc.logBacktrace(log::ERR, ex.backtrace());
// We have an exception (we should not), let's core dump.
*((int*)nullptr)=0;
} catch (std::exception & ex) {
cta::log::ScopedParamContainer params(m_lc);
params.add("exceptionWhat", ex.what());
m_lc.log(log::CRIT, "In BackendPopulator::~BackendPopulator(): error deleting agent (std::exception).");
// We have an exception (we should not), let's core dump.
*((int*)nullptr)=0;
}
......
......@@ -32,7 +32,7 @@ public:
*
* @param be The objectstore backend
*/
BackendPopulator(cta::objectstore::Backend & be, const std::string &agentType="OStoreDBFactoryAgent");
BackendPopulator(cta::objectstore::Backend & be, const std::string &agentType, const cta::log::LogContext & lc);
/**
* Destructor
......@@ -56,6 +56,11 @@ private:
* The agent
*/
cta::objectstore::AgentReference m_agentReference;
/**
* A log context (copied) in order to be able to log in destructor.
*/
cta::log::LogContext m_lc;
};
}}
\ No newline at end of file
......@@ -875,7 +875,7 @@ int DriveHandler::runChild() {
try {
std::string processName="DriveProcess-";
processName+=m_configLine.unitName;
backendPopulator.reset(new cta::objectstore::BackendPopulator(*backend, processName));
backendPopulator.reset(new cta::objectstore::BackendPopulator(*backend, processName, m_processManager.logContext()));
} catch(cta::exception::Exception &ex) {
log::ScopedParamContainer param(m_processManager.logContext());
param.add("errorMessage", ex.getMessageValue());
......
......@@ -267,7 +267,7 @@ int GarbageCollectorHandler::runChild() {
std::unique_ptr<cta::catalogue::Catalogue> catalogue;
std::unique_ptr<cta::Scheduler> scheduler;
try {
backendPopulator.reset(new cta::objectstore::BackendPopulator(*backend, "garbageCollector"));
backendPopulator.reset(new cta::objectstore::BackendPopulator(*backend, "garbageCollector", m_processManager.logContext()));
osdb.reset(new cta::OStoreDBWithAgent(*backend, backendPopulator->getAgentReference(), *catalogue, m_processManager.logContext().logger()));
const cta::rdbms::Login catalogueLogin = cta::rdbms::Login::parseFile(m_tapedConfig.fileCatalogConfigFile.value());
const uint64_t nbConns = 1;
......
......@@ -518,9 +518,7 @@ void XrdCtaFilesystem::EnvInfo(XrdOucEnv *envP)
//------------------------------------------------------------------------------
XrdCtaFilesystem::XrdCtaFilesystem():
m_xrdOucBuffPool(1024, 65536), // XrdOucBuffPool(minsz, maxsz)
m_ctaConf("/etc/cta/cta-frontend.conf"),
m_backend(cta::objectstore::BackendFactory::createBackend(m_ctaConf.getConfEntString("ObjectStore", "BackendPath", nullptr)).release()),
m_backendPopulator(*m_backend, "Frontend") {
m_ctaConf("/etc/cta/cta-frontend.conf") {
using namespace cta;
// Try to instantiate the logging system API
......@@ -539,11 +537,14 @@ XrdCtaFilesystem::XrdCtaFilesystem():
throw cta::exception::Exception(std::string("Failed to instantiate object representing CTA logging system: ")+ex.getMessage().str());
}
m_backend = std::move(cta::objectstore::BackendFactory::createBackend(m_ctaConf.getConfEntString("ObjectStore", "BackendPath", nullptr)));
m_backendPopulator = cta::make_unique<cta::objectstore::BackendPopulator>(*m_backend, "Frontend", cta::log::LogContext(*m_log));
const rdbms::Login catalogueLogin = rdbms::Login::parseFile("/etc/cta/cta_catalogue_db.conf");
const uint64_t nbConns = m_ctaConf.getConfEntInt<uint64_t>("Catalogue", "NumberOfConnections", nullptr);
const uint64_t nbArchiveFileListingConns = 2;
m_catalogue = catalogue::CatalogueFactory::create(*m_log, catalogueLogin, nbConns, nbArchiveFileListingConns);
m_scheddb = cta::make_unique<cta::OStoreDBWithAgent>(*m_backend, m_backendPopulator.getAgentReference(), *m_catalogue, *m_log);
m_scheddb = cta::make_unique<cta::OStoreDBWithAgent>(*m_backend, m_backendPopulator->getAgentReference(), *m_catalogue, *m_log);
m_scheduler = cta::make_unique<cta::Scheduler>(*m_catalogue, *m_scheddb, 5, 2*1000*1000);
// If the backend is a VFS, make sure we don't delete it on exit.
......@@ -557,7 +558,7 @@ XrdCtaFilesystem::XrdCtaFilesystem():
log(log::INFO, std::string("cta-frontend started"), params);
// Start the heartbeat thread for the agent object
m_agentHeartbeat = cta::make_unique<objectstore::AgentHeartbeatThread> (m_backendPopulator.getAgentReference(), *m_backend, *m_log);
m_agentHeartbeat = cta::make_unique<objectstore::AgentHeartbeatThread> (m_backendPopulator->getAgentReference(), *m_backend, *m_log);
m_agentHeartbeat->startThread();
}
......
......@@ -108,7 +108,7 @@ protected:
/**
* The object used to populate the backend
*/
cta::objectstore::BackendPopulator m_backendPopulator;
std::unique_ptr<cta::objectstore::BackendPopulator> m_backendPopulator;
/**
* The database or object store holding all CTA persistent objects
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment