diff --git a/GaudiTestSuite/tests/data/issue-301/options.py b/GaudiTestSuite/tests/data/issue-301/options.py new file mode 100644 index 0000000000000000000000000000000000000000..9a1b5bcf243e9f1c7add860265617c6340c5418c --- /dev/null +++ b/GaudiTestSuite/tests/data/issue-301/options.py @@ -0,0 +1,21 @@ +##################################################################################### +# (c) Copyright 2024 CERN for the benefit of the LHCb and ATLAS collaborations # +# # +# This software is distributed under the terms of the Apache version 2 licence, # +# copied verbatim in the file "LICENSE". # +# # +# In applying this licence, CERN does not waive the privileges and immunities # +# granted to it by virtue of its status as an Intergovernmental Organization # +# or submit itself to any jurisdiction. # +##################################################################################### +from pathlib import Path + +# Test exposing https://gitlab.cern.ch/gaudi/Gaudi/-/issues/301 +from Configurables import EventSelector, GaudiPersistency + +test_file_path = Path(__file__).parent / "test-file.dst" + +GaudiPersistency() +EventSelector( + Input=[f"DATAFILE='PFN:{test_file_path}' SVC='Gaudi::RootEvtSelector' OPT='READ'"] +) diff --git a/GaudiTestSuite/tests/data/issue-301/test-file.dst b/GaudiTestSuite/tests/data/issue-301/test-file.dst new file mode 100644 index 0000000000000000000000000000000000000000..e01e7ed198f1786be864af7de623cc320484a189 Binary files /dev/null and b/GaudiTestSuite/tests/data/issue-301/test-file.dst differ diff --git a/GaudiTestSuite/tests/qmtest/gauditestsuite.qms/return_codes.qms/issue-301-special-corruption.qmt b/GaudiTestSuite/tests/qmtest/gauditestsuite.qms/return_codes.qms/issue-301-special-corruption.qmt new file mode 100644 index 0000000000000000000000000000000000000000..f4faa76229daa25bd9a262cd9c134fbf90a7dc0c --- /dev/null +++ b/GaudiTestSuite/tests/qmtest/gauditestsuite.qms/return_codes.qms/issue-301-special-corruption.qmt @@ -0,0 +1,23 @@ +<?xml version="1.0" ?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'> +<!-- + (c) Copyright 2024 CERN for the benefit of the LHCb and ATLAS collaborations + + This software is distributed under the terms of the Apache version 2 licence, + copied verbatim in the file "LICENSE". + + In applying this licence, CERN does not waive the privileges and immunities + granted to it by virtue of its status as an Intergovernmental Organization + or submit itself to any jurisdiction. +--> +<extension class="GaudiTest.GaudiExeTest" kind="test"> +<argument name="program"><text>gaudirun.py</text></argument> +<argument name="args"><set> + <text>-v</text> + <text>../data/issue-301/options.py</text> +</set></argument> +<argument name="use_temp_dir"><enumeral>true</enumeral></argument> +<argument name="exit_code"><integer>16</integer></argument> +<argument name="validator"><text> +findReferenceBlock("ApplicationMgr ERROR Application Manager Terminated with error code 16") +</text></argument> +</extension> diff --git a/RootCnv/include/RootCnv/RootDataConnection.h b/RootCnv/include/RootCnv/RootDataConnection.h index 8ca7be62d4708a351bd3793516b51c8101fd5d3b..4f5c0b4f03bf0b388c532d340757182e410d75d0 100644 --- a/RootCnv/include/RootCnv/RootDataConnection.h +++ b/RootCnv/include/RootCnv/RootDataConnection.h @@ -155,7 +155,8 @@ namespace Gaudi { typedef std::set<const IInterface*> Clients; /// Allow access to printer service - MsgStream& msgSvc() const { return m_setup->msgSvc(); } + MsgStream& msgSvc() const { return m_setup->msgSvc(); } + IIncidentSvc* incidentSvc() const { return m_setup->incidentSvc(); } protected: /// Reference to the setup structure @@ -223,6 +224,7 @@ namespace Gaudi { StringVec& links() const { return c->m_links; } ParamMap& params() const { return c->m_params; } MsgStream& msgSvc() const { return c->msgSvc(); } + IIncidentSvc* incidentSvc() const { return c->incidentSvc(); } const std::string& name() const { return c->m_name; } Sections& sections() const { return c->m_sections; } LinkSections& linkSections() const { return c->m_linkSects; } diff --git a/RootCnv/src/PoolTool.h b/RootCnv/src/PoolTool.h index 5c3e11cdbadd73560de6c79868a24ee36b36e272..c34ba721736ca8df4e9adf23929f4af28bc73abf 100644 --- a/RootCnv/src/PoolTool.h +++ b/RootCnv/src/PoolTool.h @@ -9,6 +9,7 @@ * or submit itself to any jurisdiction. * \***********************************************************************************/ #include "RootCnv/PoolClasses.h" +#include <GaudiKernel/Incident.h> #include <algorithm> /* * Gaudi namespace declaration @@ -106,6 +107,7 @@ namespace Gaudi { sections()[std::string{ branch_name }] = t; return b; } + incidentSvc()->fireIncident( Incident( c->pfn(), IncidentType::CorruptedInputFile ) ); msgSvc() << MSG::ERROR << "Failed to access POOL branch:" << branch_name << " [" << tname << "]" << endmsg; t->Print(); } diff --git a/RootCnv/src/RootDataConnection.cpp b/RootCnv/src/RootDataConnection.cpp index d568cd6a1aca012b6fe920a266fadc8c15d7ec6c..c0955bc55b55160116983509ab94a3609602e546 100644 --- a/RootCnv/src/RootDataConnection.cpp +++ b/RootCnv/src/RootDataConnection.cpp @@ -18,6 +18,7 @@ // Framework include files #include "RootCnv/RootDataConnection.h" #include "GaudiKernel/DataObject.h" +#include "GaudiKernel/GaudiException.h" #include "GaudiKernel/IIncidentSvc.h" #include "GaudiKernel/IOpaqueAddress.h" #include "GaudiKernel/IRegistry.h" @@ -42,6 +43,7 @@ static int s_compressionLevel = 1; #endif // C/C++ include files +#include <fmt/format.h> #include <limits> #include <numeric> #include <stdexcept> @@ -434,6 +436,14 @@ TTree* RootDataConnection::getSection( std::string_view section, bool create ) { } } m_sections[std::string{ section }] = t; + } else { + // in some rare cases we do have the entry we expect, but we cannot read it + // https://gitlab.cern.ch/gaudi/Gaudi/-/issues/301 + auto key = m_file->GetKey( std::string{ section }.c_str() ); + if ( key ) { + incidentSvc()->fireIncident( Incident( pfn(), IncidentType::CorruptedInputFile ) ); + msgSvc() << MSG::ERROR << fmt::format( "failed to get TTree '{}' in {}", section, pfn() ) << endmsg; + } } } return t;