Commit 5dabd18a authored by Eric Cano's avatar Eric Cano
Browse files

Added logging report types in MigrationReportPacker.

The demangling has been ported in other places where RTTI was also used.
parent 224d4405
......@@ -1836,11 +1836,19 @@ std::list<std::unique_ptr<SchedulerDatabase::ArchiveJob> > OStoreDB::ArchiveMoun
// This is not a success, yet we could not confirm the job status due to an unexpected error.
// We leave the queue as is. We forget about owning this job. This is an error.
log::ScopedParamContainer params(logContext);
int demangleStatus;
char * exceptionTypeStr = abi::__cxa_demangle(typeid(e).name(), nullptr, nullptr, &demangleStatus);
params.add("tapepool", mountInfo.tapePool)
.add("queueObject", aq.getAddressIfSet())
.add("archiveRequest", (*j)->m_archiveRequest.getAddressIfSet())
.add("exceptionType", typeid(e).name())
.add("message", e.getMessageValue());
.add("archiveRequest", (*j)->m_archiveRequest.getAddressIfSet());
if (!demangleStatus) {
params.add("exceptionType", exceptionTypeStr);
} else {
params.add("exceptionType", typeid(e).name());
}
free(exceptionTypeStr);
exceptionTypeStr = nullptr;
params.add("message", e.getMessageValue());
logContext.log(log::ERR, "In ArchiveMount::getNextJobBatch(): unexpected error. Leaving the job queued.");
jobsToForget.emplace_back((*j)->m_archiveRequest.getAddressIfSet());
}
......
......@@ -294,17 +294,31 @@ m_parent(parent) {
//WorkerThread::run
//------------------------------------------------------------------------------
void MigrationReportPacker::WorkerThread::run(){
m_parent.m_lc.pushOrReplace(cta::log::Param("thread", "ReportPacker"));
// Create our own log context for the new thread.
cta::log::LogContext lc = m_parent.m_lc;
lc.pushOrReplace(cta::log::Param("thread", "ReportPacker"));
try{
while(m_parent.m_continue) {
std::unique_ptr<Report> rep (m_parent.m_fifo.pop());
{
cta::log::ScopedParamContainer params(lc);
int demangleStatus;
char * demangledReportType = abi::__cxa_demangle(typeid(*rep.get()).name(), nullptr, nullptr, &demangleStatus);
if (!demangleStatus) {
params.add("typeId", demangledReportType);
} else {
params.add("typeId", typeid(*rep.get()).name());
}
free(demangledReportType);
lc.log(cta::log::DEBUG,"In MigrationReportPacker::WorkerThread::run(): Got a new report.");
}
try{
rep->execute(m_parent);
}
catch(const failedMigrationRecallResult& e){
//here we catch a failed report MigrationResult. We try to close and if that fails too
//we end up in the catch below
m_parent.m_lc.log(cta::log::INFO,"Successfully closed client's session after the failed report MigrationResult");
lc.log(cta::log::INFO,"Successfully closed client's session after the failed report MigrationResult");
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
......@@ -315,9 +329,9 @@ void MigrationReportPacker::WorkerThread::run(){
} 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 endOfSession or endofSessionWithErrors 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());
cta::log::ScopedParamContainer params(lc);
params.add("exceptionMSG", e.getMessageValue());
lc.log(cta::log::ERR, "Tried to report endOfSession or endofSessionWithErrors and got a CTA exception, cant do much more.");
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
......@@ -325,9 +339,16 @@ void MigrationReportPacker::WorkerThread::run(){
} 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 endOfSession or endofSessionWithErrors 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());
cta::log::ScopedParamContainer params(lc);
params.add("exceptionMSG", e.what());
int demangleStatus;
char * demangleExceptionType = abi::__cxa_demangle(typeid(e).name(), nullptr, nullptr, &demangleStatus);
if (!demangleStatus) {
params.add("exceptionType", demangleExceptionType);
} else {
params.add("exceptionType", typeid(e).name());
}
lc.log(cta::log::ERR, "Tried to report endOfSession or endofSessionWithErrors and got a standard exception, cant do much more.");
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
......@@ -335,9 +356,7 @@ void MigrationReportPacker::WorkerThread::run(){
} 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 endOfSession or endofSessionWithErrors and got an unknown exception, cant do much more.";
m_parent.m_lc.log(cta::log::ERR, ssEx.str());
lc.log(cta::log::ERR, "Tried to report endOfSession or endofSessionWithErrors and got an unknown exception, cant do much more.");
if (m_parent.m_watchdog) {
m_parent.m_watchdog->addToErrorCount("Error_clientCommunication");
m_parent.m_watchdog->addParameter(cta::log::Param("status","failure"));
......@@ -348,6 +367,16 @@ void MigrationReportPacker::WorkerThread::run(){
// TODO devise a more generic mechanism
while(m_parent.m_fifo.size()) {
std::unique_ptr<Report> rep (m_parent.m_fifo.pop());
cta::log::ScopedParamContainer params(lc);
int demangleStatus;
char * demangledReportType = abi::__cxa_demangle(typeid(*rep.get()).name(), nullptr, nullptr, &demangleStatus);
if (!demangleStatus) {
params.add("typeId", demangledReportType);
} else {
params.add("typeId", typeid(*rep.get()).name());
}
free(demangledReportType);
lc.log(cta::log::DEBUG,"In MigrationReportPacker::WorkerThread::run(): Draining leftover.");
}
}
......
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