Commit 7c2d5fe0 authored by Eric Cano's avatar Eric Cano
Browse files

Reworked error handling in RecallReportPacker::WorkerThread::run()

In recalls, failing any step does not require stopping the mount nor
end the reporting so we can try and report everything until the session
is ended (by an expicit end session report).
parent afab5d82
......@@ -50,7 +50,7 @@ ReportPackerInterface<detail::Migration>(lc),
m_workerThread(*this),m_errorHappened(false),m_continue(true), m_archiveMount(archiveMount) {
}
//------------------------------------------------------------------------------
//Destructore
//Destructor
//------------------------------------------------------------------------------
MigrationReportPacker::~MigrationReportPacker(){
cta::threading::MutexLocker ml(m_producterProtection);
......
......@@ -216,54 +216,56 @@ void RecallReportPacker::WorkerThread::run(){
m_parent.m_lc.pushOrReplace(Param("thread", "RecallReportPacker"));
m_parent.m_lc.log(cta::log::DEBUG, "Starting RecallReportPacker thread");
bool endFound = false;
try{
while(1) {
std::string debugType;
std::unique_ptr<Report> rep(m_parent.m_fifo.pop());
{
cta::log::ScopedParamContainer spc(m_parent.m_lc);
spc.add("ReportType", debugType=typeid(*rep).name());
if (rep->goingToEnd())
spc.add("goingToEnd", "true");
m_parent.m_lc.log(cta::log::DEBUG, "Popping report");
}
// Record whether we found end before calling the potentially exception
// throwing execute().)
while(1) {
std::string debugType;
std::unique_ptr<Report> rep(m_parent.m_fifo.pop());
{
cta::log::ScopedParamContainer spc(m_parent.m_lc);
spc.add("ReportType", debugType=typeid(*rep).name());
if (rep->goingToEnd())
endFound=true;
rep->execute(m_parent);
if (endFound) break;
}
} catch(const cta::exception::Exception& e){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
std::stringstream ssEx;
ssEx << "Tried to report and got a CTA exception, cant do much more. The exception is the following: " << e.getMessageValue();
m_parent.m_lc.log(cta::log::ERR, ssEx.str());
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
}
} catch(const std::exception& e){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
std::stringstream ssEx;
ssEx << "Tried to report and got a standard exception, cant do much more. The exception is the following: " << e.what();
m_parent.m_lc.log(cta::log::ERR, ssEx.str());
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
spc.add("goingToEnd", "true");
m_parent.m_lc.log(cta::log::DEBUG, "Popping report");
}
} catch(...){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
std::stringstream ssEx;
ssEx << "Tried to report and got an unknown exception, cant do much more.";
m_parent.m_lc.log(cta::log::ERR, ssEx.str());
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
// Record whether we found end before calling the potentially exception
// throwing execute().)
if (rep->goingToEnd())
endFound=true;
// We can afford to see any report to fail and keep passing the following ones
// as opposed to migrations where one failure fails the session.
try {
rep->execute(m_parent);
} catch(const cta::exception::Exception& e){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
cta::log::ScopedParamContainer params(m_parent.m_lc);
params.add("exceptionWhat", e.getMessageValue())
.add("exceptionType", typeid(e).name());
m_parent.m_lc.log(cta::log::ERR, "Tried to report and got a CTA exception.");
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
}
} catch(const std::exception& e){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
cta::log::ScopedParamContainer params(m_parent.m_lc);
params.add("exceptionWhat", e.what())
.add("exceptionType", typeid(e).name());
m_parent.m_lc.log(cta::log::ERR, "Tried to report and got a standard exception.");
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
}
} catch(...){
//we get there because to tried to close the connection and it failed
//either from the catch a few lines above or directly from rep->execute
m_parent.m_lc.log(cta::log::ERR, "Tried to report and got an unknown exception.");
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
}
}
if (endFound) break;
}
// Drain the fifo in case we got an exception
if (!endFound) {
......
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