Skip to content
Snippets Groups Projects
Commit 529da440 authored by Rafal Bielski's avatar Rafal Bielski :wave:
Browse files

Improve exception handling and remove obsolete hltinterface header includes

Added try-catch blocks around hltinterface and eformat calls where missing and improved
the existing handling. Removed include of EventId, HLTResult and DataCollector headers
where not used anymore.


Former-commit-id: 197f35fc
parent cef74362
No related branches found
No related tags found
No related merge requests found
......@@ -158,24 +158,25 @@ StatusCode TrigByteStreamCnvSvc::commitOutput(const std::string& /*outputFile*/,
}
// Send output to the DataCollector
StatusCode result = StatusCode::SUCCESS;
try {
hltinterface::DataCollector::instance()->eventDone(std::move(rawEventPtr));
ATH_MSG_DEBUG("Serialised FullEventFragment with HLT result was returned to DataCollector successfully");
}
catch (const std::exception& e) {
ATH_MSG_ERROR("Sending output to DataCollector failed, caught an unexpected std::exception " << e.what());
return StatusCode::FAILURE;
result = StatusCode::FAILURE;
}
catch (...) {
ATH_MSG_ERROR("Sending output to DataCollector failed, caught an unexpected exception");
return StatusCode::FAILURE;
result = StatusCode::FAILURE;
}
ATH_MSG_DEBUG("Serialised FullEventFragment with HLT result was returned to DataCollector successfully");
delete m_rawEventWrite;
m_rawEventWrite = nullptr;
ATH_MSG_VERBOSE("end of " << __FUNCTION__);
return StatusCode::SUCCESS;
return result;
}
// =============================================================================
......@@ -216,7 +217,17 @@ void TrigByteStreamCnvSvc::printRawEvent() {
<< std::endl;
std::vector<eformat::helper::StreamTag> stream_tags;
eformat::helper::decode(m_rawEventWrite->nstream_tag(), m_rawEventWrite->stream_tag(), stream_tags);
try {
eformat::helper::decode(m_rawEventWrite->nstream_tag(), m_rawEventWrite->stream_tag(), stream_tags);
}
catch (const std::exception& ex) {
ATH_MSG_ERROR("StreamTag decoding failed, caught an unexpected std::exception " << ex.what());
return;
}
catch (...) {
ATH_MSG_ERROR("StreamTag decoding failed, caught an unexpected exception");
return;
}
ss << "--> stream_tags = ";
bool first = true;
for (const auto& st : stream_tags) {
......
......@@ -88,11 +88,23 @@ const RawEvent* TrigByteStreamInputSvc::nextEvent() {
eformat::write::FullEventFragment l1r;
using DCStatus = hltinterface::DataCollector::Status;
auto status = DCStatus::NO_EVENT;
DCStatus status = DCStatus::NO_EVENT;
do {
status = hltinterface::DataCollector::instance()->getNext(l1r);
if (status == DCStatus::NO_EVENT)
ATH_MSG_ERROR("Failed to read new event, DataCollector::getNext returned Status::NO_EVENT. Trying again.");
try {
status = hltinterface::DataCollector::instance()->getNext(l1r);
if (status == DCStatus::NO_EVENT)
ATH_MSG_ERROR("Failed to read new event, DataCollector::getNext returned Status::NO_EVENT. Trying again.");
}
catch (const std::exception& ex) {
ATH_MSG_ERROR("Failed to read new event, caught an unexpected exception: " << ex.what()
<< ". Throwing hltonl::Exception::EventSourceCorrupted" );
throw hltonl::Exception::EventSourceCorrupted();
}
catch (...) {
ATH_MSG_ERROR("Failed to read new event, caught an unexpected exception. "
<< "Throwing hltonl::Exception::EventSourceCorrupted" );
throw hltonl::Exception::EventSourceCorrupted();
}
} while (status == DCStatus::NO_EVENT);
if (status == DCStatus::STOP) {
......
......@@ -38,20 +38,19 @@ public:
virtual const RawEvent* currentEvent() const override;
private:
// ------------------------- service handles ---- ----------------------------
// ------------------------- Service handles ---------------------------------
ServiceHandle<IROBDataProviderSvc> m_robDataProviderSvc;
ServiceHandle<StoreGateSvc> m_evtStore;
// ------------------------- private data members ----------------------------
// ------------------------- Private data members ----------------------------
struct EventCache {
~EventCache();
RawEvent* rawEvent = 0; //!< current event
// unsigned int eventStatus = 0; //!< status of the current event
RawEvent* rawEvent {nullptr}; //!< Current event
};
SG::SlotSpecificObj<EventCache> m_eventsCache;
SG::SlotSpecificObj<EventCache> m_eventsCache; //!< Cache of RawEvent pointer per event slot
// ------------------------- private helper methods --------------------------
// ------------------------- Private helper methods --------------------------
/// Clean up parts of previous event and re-init them
void releaseEvent(EventCache* cache);
};
......
......@@ -14,9 +14,6 @@
#include "EventInfo/EventInfo.h"
#include "StoreGate/StoreGateSvc.h"
// TDAQ includes
#include "hltinterface/DataCollector.h"
// =============================================================================
// Standard constructor
// =============================================================================
......@@ -78,12 +75,16 @@ StatusCode TrigEventSelectorByteStream::next(IEvtSelector::Context& /*c*/) const
ATH_MSG_INFO(e.what());
throw; // rethrow NoMoreEvents
}
catch (const hltonl::Exception::EventSourceCorrupted& e) {
ATH_MSG_ERROR(e.what());
throw; // rethrow EventSourceCorrupted
}
catch (const std::exception& e) {
ATH_MSG_ERROR("Failed to get next event from the event source, std::exception caught: " << e.what());
return StatusCode::FAILURE;
}
catch (...) {
ATH_MSG_ERROR("Failed to get next event from the event source, unhandled exception caught");
ATH_MSG_ERROR("Failed to get next event from the event source, unknown exception caught");
return StatusCode::FAILURE;
}
......
......@@ -11,7 +11,7 @@ atlas_depends_on_subdirs( PUBLIC
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( tdaq-common COMPONENTS eformat hltinterface )
find_package( tdaq-common COMPONENTS eformat )
# Component(s) in the package:
atlas_add_library( TrigKernel
......
......@@ -11,7 +11,7 @@ namespace hltonl {
namespace Exception {
/**
* @class NoMoreEvents
* @brief Can be thrown if all events are already read from the input and another one is requested
* @brief Thrown if all events are already read from the input and another one is requested
*/
class NoMoreEvents : public std::exception {
public:
......@@ -19,6 +19,16 @@ namespace hltonl {
virtual ~NoMoreEvents() {}
const char* what() const noexcept override {return "No more events to be processed";}
};
/**
* @class EventSourceCorrupted
* @brief Thrown if event source keeps throwing exceptions when new event is requested
*/
class EventSourceCorrupted : public std::exception {
public:
EventSourceCorrupted() {}
virtual ~EventSourceCorrupted() {}
const char* what() const noexcept override {return "Event source corrupted and cannot provide events";}
};
}
}
......
......@@ -8,12 +8,6 @@
#include "GaudiKernel/IInterface.h"
#include <boost/property_tree/ptree.hpp>
namespace hltinterface
{
struct EventId;
struct HLTResult;
}
/**@class ITrigEventLoopMgr
* @brief EventLoopMgr interface implemented by the HLT event loop manager
*
......
......@@ -15,10 +15,6 @@
// Package includes
#include "hltinterface/HLTInterface.h"
#include "hltinterface/EventId.h"
// to be removed together with the Psc::process method
#include "hltinterface/HLTResult.h"
// Gaudi Includes
#include "GaudiKernel/StatusCode.h"
......
......@@ -36,7 +36,6 @@
// TDAQ includes
#include "eformat/StreamTag.h"
#include "hltinterface/DataCollector.h"
#include "owl/time.h"
// System includes
......@@ -696,7 +695,12 @@ StatusCode HltEventLoopMgr::nextEvent(int /*maxevt*/)
}
continue;
}
catch (const std::exception& e) {
ATH_MSG_ERROR("Failed to get next event from the event source, std::exception caught: " << e.what());
sc = StatusCode::FAILURE;
}
catch (...) {
ATH_MSG_ERROR("Failed to get next event from the event source, unknown exception caught");
sc = StatusCode::FAILURE;
}
HLT_EVTLOOP_CHECK(sc, "Failed to get the next event",
......@@ -1055,14 +1059,14 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< "Failure occurred with PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode)
<< " meaning there was a framework error before requesting a new event. No output will be produced and all slots"
<< " of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
else if (errorCode==hltonl::PSCErrorCode::AFTER_RESULT_SENT) {
ATH_REPORT_MESSAGE(MSG::ERROR)
<< "Failure occurred with PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode)
<< " meaning there was a framework error after HLT result was already sent out."
<< " All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
else if (errorCode==hltonl::PSCErrorCode::CANNOT_ACCESS_SLOT) {
ATH_REPORT_MESSAGE(MSG::ERROR)
......@@ -1070,14 +1074,26 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< hltonl::PrintPscErrorCode(errorCode)
<< ". All slots of this HltEventLoopMgr instance will be drained before proceeding, then either the loop will"
<< " exit with a failure code or the failed event will reach a hard timeout.";
return drainAllAndProceed();
return drainAllAndProceed();
}
else if (!eventContext.valid()) {
ATH_REPORT_MESSAGE(MSG::ERROR)
<< "Failure occurred with an invalid EventContext. Likely there was a framework error before requesting a new"
<< " event or after sending the result of a finished event. PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode)
<< ". All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
//----------------------------------------------------------------------------
// In case of event source failure, drain the scheduler and break the loop
//----------------------------------------------------------------------------
if (errorCode==hltonl::PSCErrorCode::CANNOT_RETRIEVE_EVENT) {
ATH_REPORT_MESSAGE(MSG::ERROR)
<< "Failure occurred with PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode)
<< " meaning a new event could not be correctly read. No output will be produced for this event. All slots of"
<< " this HltEventLoopMgr instance will be drained and the loop will exit.";
ATH_CHECK(drainAllSlots());
return StatusCode::FAILURE;
}
//----------------------------------------------------------------------------
......@@ -1106,7 +1122,7 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< " event processing started or not. Current local event number is " << eventContext.evt()
<< ", slot " << eventContext.slot() << ". " << eventInfoString
<< " All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
//----------------------------------------------------------------------------
......@@ -1133,7 +1149,7 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< " PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode) << ", local event number " << eventContext.evt()
<< ", slot " << eventContext.slot() << ". " << eventInfoString
<< " All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
//----------------------------------------------------------------------------
......@@ -1153,7 +1169,7 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< " recorded for this event. PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode) << ", local event number "
<< eventContext.evt() << ", slot " << eventContext.slot() << ". " << eventInfoString
<< " All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
DataObject* hltResultDO = m_evtStore->accessData(hltResultWH.clid(),hltResultWH.key());
......@@ -1163,7 +1179,7 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< " can be recorded for this event. PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode)
<< ", local event number " << eventContext.evt() << ", slot " << eventContext.slot() << ". " << eventInfoString
<< " All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
IOpaqueAddress* addr = nullptr;
......@@ -1173,7 +1189,7 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< " can be recorded for this event. PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode)
<< ", local event number " << eventContext.evt() << ", slot " << eventContext.slot() << ". " << eventInfoString
<< " All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
if (m_outputCnvSvc->commitOutput("",true).isFailure()) {
......@@ -1182,7 +1198,7 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< " recorded for this event. PSCErrorCode=" << hltonl::PrintPscErrorCode(errorCode) << ", local event number "
<< eventContext.evt() << ", slot " << eventContext.slot() << ". " << eventInfoString
<< " All slots of this HltEventLoopMgr instance will be drained before proceeding.";
return drainAllAndProceed();
return drainAllAndProceed();
}
//----------------------------------------------------------------------------
......@@ -1206,8 +1222,8 @@ StatusCode HltEventLoopMgr::failedEvent(hltonl::PSCErrorCode errorCode, const Ev
<< m_maxFrameworkErrors.value() << ", was exceeded. Current local event number is " << eventContextCopy.evt()
<< ", slot " << eventContextCopy.slot() << ". " << eventInfoString
<< " All slots of this HltEventLoopMgr instance will be drained and the loop will exit.";
ATH_CHECK(drainAllSlots());
return StatusCode::FAILURE;
ATH_CHECK(drainAllSlots());
return StatusCode::FAILURE;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment