ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbSvc Class Reference

Athena service for Interval Of Validity database. More...

#include <IOVDbSvc.h>

Inheritance diagram for IOVDbSvc:

Public Types

typedef IAddressProvider::tadList tadList
typedef IAddressProvider::tadListIterator tadListIterator

Public Member Functions

virtual StatusCode initialize () override
 Service init.
StatusCode io_reinit () override final
virtual StatusCode finalize () override
 Service finalize.
StatusCode io_finalize () override final
virtual cool::IDatabasePtr getDatabase (bool readOnly) override
 Access to COOL database for a given folder.
Address use
virtual StatusCode preLoadAddresses (StoreID::type storeID, tadList &list) override
 Get all addresses that the provider wants to preload in SG maps.
virtual StatusCode loadAddresses (StoreID::type storeID, tadList &list) override
 Get all new addresses from Provider for this Event.
virtual StatusCode updateAddress (StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
 Update a transient Address.

IOV range access

enum  IOVDbSvc_state { INITIALIZATION = 0 , BEGIN_RUN , EVENT_LOOP , FINALIZE_ALG }
typedef std::map< std::string, std::unique_ptr< IOVDbFolder > > FolderMap
Gaudi::Property< std::string > m_par_defaultConnection {this,"dbConnection","sqlite://;schema=cooldummy.db;dbname=OFLP200","default DB connection string"}
Gaudi::Property< std::string > m_par_globalTag {this,"GlobalTag","","Global database tag"}
Gaudi::Property< std::string > m_par_dbinst {this,"DBInstance","","Database instance (like OFLP200)"}
Gaudi::Property< std::vector< std::string > > m_par_folders {this,"Folders",{},"List of database folders to preload","OrderedSet<std::string>"}
Gaudi::Property< std::vector< std::string > > m_par_overrideTags {this,"overrideTags",{},"List of xml-modifiers for folders like <prefix>/My/Folder</prefix><tag>MyFolderTag</tag>","OrderedSet<std::string>"}
Gaudi::Property< std::vector< std::string > > m_par_foldersToWrite {this,"FoldersToMetaData",{},"list of folders to write to file meta data","OrderedSet<std::string>"}
BooleanProperty m_par_manageConnections {this,"ManageConnections",true,"flag to trigger the connections management"}
BooleanProperty m_par_managePoolConnections {this,"ManagePoolConnections",true,"flag to manage pool connections"}
IntegerProperty m_par_forceRunNumber {this,"forceRunNumber",0,"globally force run-number (default: no force)"}
IntegerProperty m_par_forceLumiblockNumber {this,"forceLumiblockNumber",0,"globally force LB-number (default: no force)"}
IntegerProperty m_par_forceTimestamp {this,"forceTimeStamp",0,"globally force time-stamp (default: no force)"}
IntegerProperty m_par_maxNumPoolFiles {this,"MaxPoolFilesOpen",5,"max number of pool files open allowed (0 means no limit)"}
FloatProperty m_par_timeStampSlop {this,"TimeStampSlop",0.0,"backdata timestamp IOVs by this many seconds"}
IntegerProperty m_par_cacheRun {this,"CacheRun",0,"force larger numbers of runs to be cached"}
IntegerProperty m_par_cacheTime {this,"CacheTime",0,"force larger timeranges to be cached (seconds)"}
UnsignedIntegerProperty m_par_cacheAlign {this,"CacheAlign",0,"cache alignment - divide cache into N slices and align queries on slice"}
BooleanProperty m_par_onlineMode {this,"OnlineMode",false,"online mode flag to ignore missing channels outside cache range"}
BooleanProperty m_par_checklock {this,"CheckLock",false,"check to ensure global/HVS tags are locked (for production)"}
StringProperty m_par_source {this,"Source","COOL_DATABASE","source of data as a string (default COOL_DATABASE)"}
StringProperty m_par_crestServer {this,"crestServer","https://crest.cern.ch","CREST URL with the port number as a string (default https://crest.cern.ch)"}
std::map< std::string, std::string > m_cresttagmap
StringProperty m_par_format {this,"Format",{},"Format of data; default is empty string (default for a given source)"}
BooleanProperty m_outputToFile {this,"OutputToFile",false,"output to file for debugging purposes"}
BooleanProperty m_crestCoolToFile {this,"CrestCoolToFile",false,"output to file crest or cool data in the same format for debugging purposes"}
ServiceHandle< IIOVSvcm_h_IOVSvc {this,"IOVSvc","IOVSvc"}
ServiceHandle< StoreGateSvcm_h_sgSvc {this,"StoreGateSvc","StoreGateSvc"}
ServiceHandle< StoreGateSvcm_h_detStore {this,"DetectorStore","DetectorStore"}
ServiceHandle< StoreGateSvcm_h_metaDataStore {this,"MetaDataStore","StoreGateSvc/MetaDataStore"}
ServiceHandle< IAddressCreator > m_h_persSvc {this,"EventPersistencySvc","EventPersistencySvc"}
ServiceHandle< IClassIDSvc > m_h_clidSvc {this,"ClassIDSvc","ClassIDSvc"}
ServiceHandle< IPoolSvcm_h_poolSvc {this,"PoolSvc","PoolSvc"}
PublicToolHandle< IIOVDbMetaDataToolm_h_metaDataTool {this,"IOVDbMetaDataTool","IOVDbMetaDataTool"}
ServiceHandle< ITagInfoMgrm_h_tagInfoMgr {this,"TagInfoMgr","TagInfoMgr"}
bool m_poolPayloadRequested {false}
int m_poolSvcContext {-1}
IOVDbSvc_state m_state {INITIALIZATION}
IOVTime m_iovTime {}
std::string m_globalTag {}
cool::ValidityKey m_iovslop {}
std::vector< std::unique_ptr< IOVDbConn > > m_connections
FolderMap m_foldermap
bool m_abort {false}
virtual StatusCode getRange (const CLID &clid, const std::string &dbKey, const IOVTime &time, IOVRange &range, std::string &tag, std::unique_ptr< IOpaqueAddress > &ioa) override
 Get range for a particular data object identified by its clid and key and a requested IOVTime.
virtual StatusCode setRange (const CLID &clid, const std::string &dbKey, const IOVRange &range, const std::string &tag) override
 Set range for a particular data object.
virtual StatusCode signalBeginRun (const IOVTime &beginRunTime, const EventContext &ctx) override
 Set time for begin run.
virtual void signalEndProxyPreload () override
 Signal that callback has been fired.
virtual void postConditionsLoad () override
 May be called once conditions are loaded to let IOVDbSvc release resources.
virtual void handle (const Incident &incident) override
 Incident service handle for EndEvent.
virtual StatusCode processTagInfo () override
 Process TagInfo.
virtual std::vector< std::string > getKeyList () override
virtual bool getKeyInfo (const std::string &key, IIOVDbSvc::KeyInfo &info) override
 Return information about SG key return false if this key is not known to IOVDbSvc.
virtual bool dropObject (const std::string &key, const bool resetCache=false) override
StatusCode checkConfigConsistency () const
StatusCode checkEventSel ()
StatusCode setupFolders ()
StatusCode fillTagInfo ()
StatusCode loadCaches (IOVDbConn *conn, const IOVTime *time=nullptr)
int poolSvcContext ()

Detailed Description

Athena service for Interval Of Validity database.

The IOVDbSvc may be in one of three time states which determines from where the IOV time is coming: initialization - IOV time must be set from the EventSelector begin run - IOV time should have been set with signalBeginRun event loop - IOV time is from EventInfo

Definition at line 66 of file IOVDbSvc.h.

Member Typedef Documentation

◆ FolderMap

typedef std::map<std::string, std::unique_ptr<IOVDbFolder> > IOVDbSvc::FolderMap
private

Definition at line 269 of file IOVDbSvc.h.

◆ tadList

Definition at line 91 of file IOVDbSvc.h.

◆ tadListIterator

Member Enumeration Documentation

◆ IOVDbSvc_state

Enumerator
INITIALIZATION 
BEGIN_RUN 
EVENT_LOOP 
FINALIZE_ALG 

Definition at line 248 of file IOVDbSvc.h.

248 {
249 INITIALIZATION = 0,
250 BEGIN_RUN,
253 };
@ FINALIZE_ALG
Definition IOVDbSvc.h:252
@ BEGIN_RUN
Definition IOVDbSvc.h:250
@ INITIALIZATION
Definition IOVDbSvc.h:249
@ EVENT_LOOP
Definition IOVDbSvc.h:251

Member Function Documentation

◆ checkConfigConsistency()

StatusCode IOVDbSvc::checkConfigConsistency ( ) const
private

Definition at line 1142 of file IOVDbSvc.cxx.

1142 {
1143 // check consistency of global tag and database instance, if set
1144 // catch most common user misconfigurations
1145 // this is only done here as need global tag to be set even if read from file
1146 // @TODO should this not be done during initialize
1147
1148 if (!m_par_dbinst.empty() && !m_globalTag.empty() && m_par_source!="CREST") {
1149 const std::string_view tagstub = std::string_view(m_globalTag).substr(0,7);
1150 ATH_MSG_DEBUG( "Checking " << m_par_dbinst << " against " <<tagstub );
1151
1152 if ( ((m_par_dbinst=="COMP200" || m_par_dbinst=="CONDBR2") &&
1153 (tagstub!="COMCOND" && tagstub!="CONDBR2")) ||
1154 (m_par_dbinst=="OFLP200" && (tagstub!="OFLCOND" && tagstub!="CMCCOND")) ) {
1155
1156 ATH_MSG_FATAL( "Likely incorrect conditions DB configuration! " <<
1157 "Attached to database instance " << m_par_dbinst <<
1158 " but global tag begins " << tagstub );
1159 ATH_MSG_FATAL( "See Atlas/CoolTroubles wiki for details,"
1160 " or set IOVDbSvc.DBInstance=\"\" to disable check" );
1161 return StatusCode::FAILURE;
1162 }
1163 }
1164 return StatusCode::SUCCESS;
1165}
#define ATH_MSG_FATAL(x)
#define ATH_MSG_DEBUG(x)
Gaudi::Property< std::string > m_par_dbinst
Definition IOVDbSvc.h:178
StringProperty m_par_source
Definition IOVDbSvc.h:211
std::string m_globalTag
Definition IOVDbSvc.h:260

◆ checkEventSel()

StatusCode IOVDbSvc::checkEventSel ( )
private

Definition at line 845 of file IOVDbSvc.cxx.

845 {
846 // check if EventSelector is being used to override run numbers
847 // if so, we can set IOV time already to allow conditons retrieval
848 // in the initialise phase, needed for setting up simulation
849
850 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc",name());
851 ATH_CHECK( joSvc.retrieve() );
852
853 if (!joSvc->has("EventSelector.OverrideRunNumber")) {
854 // do not return FAILURE if the EventSelector cannot be found, or it has
855 // no override property, can e.g. happen in online running
856 ATH_MSG_DEBUG( "No EventSelector.OverrideRunNumber property found" );
857 return StatusCode::SUCCESS;
858 }
859
860 BooleanProperty overrideRunNumber("OverrideRunNumber",false);
861 ATH_CHECK( overrideRunNumber.fromString(joSvc->get("EventSelector.OverrideRunNumber")) );
862 if (overrideRunNumber) {
863 // if flag is set, extract Run,LB and time
864 ATH_MSG_INFO( "Setting run/LB/time from EventSelector override in initialize" );
865 uint32_t run,lumib;
867 bool allGood=true;
869 ATH_MSG_WARNING( "forceRunNumber property also set" );
870 }
871 IntegerProperty iprop1("RunNumber",0);
872 if (iprop1.fromString(joSvc->get("EventSelector.RunNumber","INVALID"))) {
873 run=iprop1;
874 } else {
875 ATH_MSG_ERROR( "Unable to get RunNumber from EventSelector");
876 allGood=false;
877 }
878 IntegerProperty iprop2("FirstLB",0);
879 if (iprop2.fromString(joSvc->get("EventSelector.FirstLB","INVALID"))) {
880 lumib=iprop2;
881 } else {
882 ATH_MSG_ERROR( "Unable to get FirstLB from EventSelector");
883 allGood=false;
884 }
885 IntegerProperty iprop3("InitialTimeStamp",0);
886 if (iprop3.fromString(joSvc->get("EventSelector.InitialTimeStamp","INVALID"))) {
887 time=iprop3;
888 } else {
889 ATH_MSG_ERROR("Unable to get InitialTimeStamp from EventSelector" );
890 allGood=false;
891 }
892 if (allGood) {
893 m_iovTime.setRunEvent(run,lumib);
894 uint64_t nsTime=time*1000000000LL;
895 m_iovTime.setTimestamp(nsTime);
896 ATH_MSG_INFO( "run/LB/time set to [" << run << "," << lumib << " : " << nsTime << "]" );
897 } else {
898 ATH_MSG_ERROR( "run/LB/Time NOT changed" );
899 }
900 }
901
902 return StatusCode::SUCCESS;
903}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
IntegerProperty m_par_forceLumiblockNumber
Definition IOVDbSvc.h:192
IOVTime m_iovTime
Definition IOVDbSvc.h:257
IntegerProperty m_par_forceRunNumber
Definition IOVDbSvc.h:190
time(flags, cells_name, *args, **kw)
bool allGood
Loop over the SDOs & Digits.
setEventNumber uint32_t
int run(int argc, char *argv[])

◆ dropObject()

bool IOVDbSvc::dropObject ( const std::string & key,
const bool resetCache = false )
overridevirtual

Definition at line 817 of file IOVDbSvc.cxx.

817 {
818 // find the folder corresponding to this object
819 const auto itr = m_foldermap.find(key);
820 if (itr!=m_foldermap.end()) {
821 IOVDbFolder* folder=itr->second.get();
822 CLID clid=folder->clid();
823 SG::DataProxy* proxy=m_h_detStore->proxy(clid,key);
824 if (proxy!=nullptr) {
825 m_h_detStore->clearProxyPayload(proxy);
826 ATH_MSG_DEBUG("Dropped payload for key " << key );
827 folder->setDropped(true);
828 if (resetCache) {
829 folder->resetCache();
830 ATH_MSG_DEBUG( "Cache reset done for folder " << folder->folderName() );
831 }
832 return true;
833 } else {
834 return false;
835 }
836 } else {
837 return false;
838 }
839}
uint32_t CLID
The Class ID type.
ServiceHandle< StoreGateSvc > m_h_detStore
Definition IOVDbSvc.h:225
FolderMap m_foldermap
Definition IOVDbSvc.h:270

◆ fillTagInfo()

StatusCode IOVDbSvc::fillTagInfo ( )
private

Definition at line 1065 of file IOVDbSvc.cxx.

1065 {
1066 if (!m_par_globalTag.empty()) {
1067 ATH_MSG_DEBUG( "Adding GlobalTag " << m_par_globalTag << " into TagInfo" );
1068 ATH_CHECK( m_h_tagInfoMgr->addTag("IOVDbGlobalTag",m_par_globalTag) );
1069 }
1070 // add all explicit tags specified in folders
1071 // can be from Folders or tagOverrides properties
1072 for (const auto & [name, folder] : m_foldermap) {
1073 if (!folder->joTag().empty()) {
1074 ATH_MSG_DEBUG( "Adding folder " << folder->folderName() <<" tag " << folder->joTag() << " into TagInfo" );
1075 if (m_h_tagInfoMgr->addTag(folder->folderName(),folder->joTag()).isFailure())
1076 return StatusCode::FAILURE;
1077 }
1078 // check to see if any input TagInfo folder overrides should be removed
1079 // this anticipates the decisions which will be made in processTagInfo
1080 // Here we do not have access to the TagInfo object, but can put remove
1081 // requests in for all folders if the global tag is set, or if there is
1082 // an explict joboption tag, nooverride spec, or data comes from metadata
1083 if (!m_par_globalTag.empty() || !folder->joTag().empty() || folder->noOverride() ||
1084 folder->readMeta()) {
1085 if (m_h_tagInfoMgr->removeTagFromInput(folder->folderName()).isFailure()) {
1086 ATH_MSG_WARNING( "Could not add TagInfo remove request for "
1087 << folder->folderName() );
1088 } else {
1089 ATH_MSG_INFO( "Added taginfo remove for " << folder->folderName() );
1090 }
1091 }
1092 }
1093 return StatusCode::SUCCESS;
1094}
ServiceHandle< ITagInfoMgr > m_h_tagInfoMgr
Definition IOVDbSvc.h:231
Gaudi::Property< std::string > m_par_globalTag
Definition IOVDbSvc.h:176

◆ finalize()

StatusCode IOVDbSvc::finalize ( )
overridevirtual

Service finalize.

Definition at line 234 of file IOVDbSvc.cxx.

234 {
235 // summarise and delete folders, adding total read from COOL
236 unsigned long long nread = 0;
237 float readtime = 0;
238
239 // accumulate a map of readtime by connection
240 std::map<IOVDbConn*, float> ctmap;
241 for (const auto & [name, folder] : m_foldermap) {
242 folder->summary();
243 nread += folder->bytesRead();
244 readtime += folder->readTime();
245 const auto& [citr, inserted] = ctmap.try_emplace(folder->conn(), 0);
246 citr->second += folder->readTime();
247 }
248 m_foldermap.clear();
249 ATH_MSG_INFO( "Total payload read from IOVDb: " << nread << " bytes in (( " << std::fixed << std::setw(9) << std::setprecision(2) <<
250 readtime << " ))s" );
251
252 // close and delete connections, printing time in each one
253 for (const auto & conn : m_connections) {
254 float fread = 0;
255 const auto citr = ctmap.find(conn.get());
256 if (citr != ctmap.end()) fread = citr->second;
257 conn->setInactive();
258 conn->summary(fread);
259 }
260 m_connections.clear();
261
262 return StatusCode::SUCCESS;
263}
std::vector< std::unique_ptr< IOVDbConn > > m_connections
Definition IOVDbSvc.h:266

◆ getDatabase()

cool::IDatabasePtr IOVDbSvc::getDatabase ( bool readOnly)
overridevirtual

Access to COOL database for a given folder.

Definition at line 266 of file IOVDbSvc.cxx.

266 {
267 // get default database connection
268 cool::IDatabasePtr dbconn;
269 if (m_par_defaultConnection.empty() || m_connections.empty()) {
270 ATH_MSG_INFO( "No default COOL database connection is available");
271 dbconn.reset();
272 } else {
273 Athena::DBLock dblock;
274 if (m_connections[0]->isReadOnly()!=readOnly) {
275 ATH_MSG_INFO("Changing state of default connection to readonly=" << readOnly );
276 m_connections[0]->setReadOnly(readOnly);
277 }
278 dbconn = std::make_shared<LockedDatabase> (m_connections[0]->getCoolDb(),
279 dblock);
280 }
281 return dbconn;
282}
Gaudi::Property< std::string > m_par_defaultConnection
Definition IOVDbSvc.h:174

◆ getKeyInfo()

bool IOVDbSvc::getKeyInfo ( const std::string & key,
IIOVDbSvc::KeyInfo & info )
overridevirtual

Return information about SG key return false if this key is not known to IOVDbSvc.

Definition at line 796 of file IOVDbSvc.cxx.

796 {
797 // return information about given SG key
798 // first attempt to find the folder object for this key
799 const auto itr = m_foldermap.find(key);
800 if (itr!=m_foldermap.end()) {
801 const IOVDbFolder* f = itr->second.get();
802 info.folderName = f->folderName();
803 info.tag = f->resolvedTag();
804 info.range = f->currentRange();
805 info.retrieved = f->retrieved();
806 info.bytesRead = f->bytesRead();
807 info.readTime = f->readTime();
808 info.extensible = f->extensible();
809 return true;
810 } else {
811 info.retrieved = false;
812 return false;
813 }
814}

◆ getKeyList()

std::vector< std::string > IOVDbSvc::getKeyList ( )
overridevirtual

Definition at line 789 of file IOVDbSvc.cxx.

789 {
790 // return a list of all the StoreGate keys being managed by IOVDbSvc
791 auto keys = std::views::keys(m_foldermap);
792 return {keys.begin(), keys.end()};
793}

◆ getRange()

StatusCode IOVDbSvc::getRange ( const CLID & clid,
const std::string & dbKey,
const IOVTime & time,
IOVRange & range,
std::string & tag,
std::unique_ptr< IOpaqueAddress > & ioa )
overridevirtual

Get range for a particular data object identified by its clid and key and a requested IOVTime.

Definition at line 532 of file IOVDbSvc.cxx.

537 {
538
539 Athena::DBLock dblock;
540
541 ATH_MSG_DEBUG( "getRange clid: " << clid << " key: \""<< dbKey << "\" t: " << time );
542
543 const auto fitr = m_foldermap.find(dbKey);
544 if (fitr==m_foldermap.end()) {
545 ATH_MSG_VERBOSE("getRange cannot find description for dbKey " << dbKey );
546 return StatusCode::FAILURE;
547 }
548 const auto& folder = fitr->second;
549 if (folder->clid()!=clid) {
550 ATH_MSG_VERBOSE( "supplied CLID for " << dbKey << " is "
551 << clid
552 << " but expecting " << folder->clid() );
553
554 return StatusCode::FAILURE;
555 }
556
557 tag = folder->key();
558
559 // obtain the validity key for this folder (includes overrides)
560 cool::ValidityKey vkey=folder->iovTime(time);
561 if (!folder->readMeta() && !folder->cacheValid(vkey)) {
562 // mark this folder as not-dropped so cache-read will succeed
563 folder->setDropped(false);
564 // reload cache for this folder (and all others sharing this DB connection)
565 ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName() );
566 if (loadCaches(folder->conn(),&time).isFailure()) {
567 ATH_MSG_ERROR( "Cache load failed for at least one folder from " << folder->conn()->name()
568 << ". You may see errors from other folders sharing the same connection." );
569 return StatusCode::FAILURE;
570 }
571 }
572
573 // data should now be in cache
574 address.reset();
575 // setup address and range
576 {
577 Gaudi::Guards::AuditorGuard auditor(std::string("FldrSetup:")+(dbKey.empty() ? "anonymous" : dbKey),
578 auditorSvc(), "preLoadProxy");
579 if (!folder->getAddress(vkey,&(*m_h_persSvc),poolSvcContext(),address,
580 range,m_poolPayloadRequested)) {
581 ATH_MSG_ERROR("getAddress failed for folder " <<folder->folderName() );
582 return StatusCode::FAILURE;
583 }
584 }
585
586 // Special handling for extensible folders:
587 if (folder->extensible()) {
588 // Set the end time to just past the current event or lumiblock.
589 IOVTime extStop = range.stop();
590 if (folder->timeStamp()) {
591 extStop.setTimestamp (time.timestamp() + 1);
592 }
593 else {
594 extStop.setRETime (time.re_time() + 1);
595 }
596 range = IOVRange (range.start(), extStop);
597 }
598
599 // Special handling for IOV override: set the infinite validity range
600 if (folder->iovOverridden()) {
601 if (folder->timeStamp()) {
602 range = IOVRange ( IOVTime(IOVTime::MINTIMESTAMP),
603 IOVTime(IOVTime::MAXTIMESTAMP) );
604 }
605 else {
606 range = IOVRange ( IOVTime(IOVTime::MINRUN,IOVTime::MINEVENT),
608 }
609 }
610
611 return StatusCode::SUCCESS;
612}
#define ATH_MSG_VERBOSE(x)
StatusCode loadCaches(IOVDbConn *conn, const IOVTime *time=nullptr)
ServiceHandle< IAddressCreator > m_h_persSvc
Definition IOVDbSvc.h:227
int poolSvcContext()
Definition IOVDbSvc.cxx:123
bool m_poolPayloadRequested
Definition IOVDbSvc.h:236
static constexpr uint64_t MAXTIMESTAMP
Definition IOVTime.h:58
static constexpr uint32_t MAXRUN
Definition IOVTime.h:48
void setRETime(uint64_t time) noexcept
Definition IOVTime.cxx:84
static constexpr uint32_t MINEVENT
Definition IOVTime.h:50
static constexpr uint64_t MINTIMESTAMP
Definition IOVTime.h:56
void setTimestamp(uint64_t timestamp) noexcept
Definition IOVTime.cxx:72
static constexpr uint32_t MAXEVENT
Definition IOVTime.h:51
static constexpr uint32_t MINRUN
Definition IOVTime.h:44

◆ handle()

void IOVDbSvc::handle ( const Incident & incident)
overridevirtual

Incident service handle for EndEvent.

Definition at line 726 of file IOVDbSvc.cxx.

726 {
727 // Handle incidents:
728 // BeginEvent to set IOVDbSvc state to EVENT_LOOP
729 // StoreCleared/EndProcessing to close any open POOL files
730 ATH_MSG_VERBOSE( "entering handle(), incident type " << inc.type() << " from " << inc.source() );
731 if (inc.type()=="BeginEvent") {
733 } else {
734 Athena::DBLock dblock;
735
736 const StoreClearedIncident* sinc = dynamic_cast<const StoreClearedIncident*>(&inc);
737 if( (inc.type()=="StoreCleared" && sinc!=nullptr && sinc->store()==&*m_h_sgSvc
739 or inc.type()==IncidentType::EndProcessing )
740 {
743 }
744 }
745}
ServiceHandle< StoreGateSvc > m_h_sgSvc
Definition IOVDbSvc.h:224
virtual void postConditionsLoad() override
May be called once conditions are loaded to let IOVDbSvc release resources.
Definition IOVDbSvc.cxx:700
IOVDbSvc_state m_state
Definition IOVDbSvc.h:254
const StoreGateSvc * store() const
Return the store that was cleared.

◆ initialize()

StatusCode IOVDbSvc::initialize ( )
overridevirtual

Service init.

Definition at line 143 of file IOVDbSvc.cxx.

143 {
144 // subscribe to events
145 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc",name());
146 ATH_CHECK( incSvc.retrieve() );
147 const long int pri = 100;
148 incSvc->addListener( this, IncidentType::BeginEvent, pri );
149 incSvc->addListener( this, "StoreCleared", pri ); // for SP Athena
150 incSvc->addListener( this, IncidentType::EndProcessing, pri ); // for MT Athena
151
152 // Register this service for 'I/O' events
153 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
154 ATH_CHECK( iomgr.retrieve() );
155 ATH_CHECK( iomgr->io_register(this) );
156
157 // print warnings/info depending on state of job options
159 ATH_MSG_INFO( "COOL connection management disabled - connections kept open throughout job" );
161 ATH_MSG_INFO( "POOL file connection management disabled - files kept open throught job" );
162 if (m_par_maxNumPoolFiles > 0)
163 ATH_MSG_INFO( "Only " << m_par_maxNumPoolFiles.value() << " POOL conditions files will be open at once" );
165 ATH_MSG_WARNING( "Global run/LB number forced to be [" <<
166 m_par_forceRunNumber.value() << "," << m_par_forceLumiblockNumber.value() << "]" );
167 if (m_par_forceTimestamp > 0)
168 ATH_MSG_WARNING( "Global timestamp forced to be " << m_par_forceTimestamp.value() );
169 if (m_par_cacheRun > 0)
170 ATH_MSG_INFO( "Run-LB data will be cached in groups of " << m_par_cacheRun.value() << " runs" );
171 if (m_par_cacheTime > 0)
172 ATH_MSG_INFO( "Timestamp data will be cached in groups of " << m_par_cacheTime.value() << " seconds" );
173 if (m_par_cacheAlign > 0)
174 ATH_MSG_INFO( "Cache alignment will be done in " << m_par_cacheAlign.value() << " slices" );
175 if (m_par_onlineMode)
176 ATH_MSG_INFO( "Online mode ignoring potential missing channels outside cache" );
177 if (m_par_checklock)
178 ATH_MSG_INFO( "Tags will be required to be locked");
179
180 // make sure iovTime is undefined
181 m_iovTime.reset();
182
183 // extract information from EventSelector for run/LB/time overrides
185
186 // initialise default connection
187 if (!m_par_defaultConnection.empty()) {
188 // default connection is readonly if no : in name (i.e. logical conn)
189 bool readonly=(m_par_defaultConnection.find(':')==std::string::npos);
190 m_connections.push_back(std::make_unique<IOVDbConn>(m_par_defaultConnection,readonly,msg()));
191 }
192
193 // set time of timestampslop in nanoseconds
194 m_iovslop=static_cast<cool::ValidityKey>(m_par_timeStampSlop*1.E9);
195
196 // check for global tag in jobopt, which will override anything in input file
197 if (!m_par_globalTag.empty()) {
199 ATH_MSG_INFO( "Global tag: " << m_par_globalTag.value() << " set from joboptions" );
200 }
201
202 // setup folders and process tag overrides
204
205 // Set state to initialize
207 ATH_MSG_INFO( "Initialised with " << m_connections.size() <<
208 " connections and " << m_foldermap.size() << " folders" );
209
210 if (m_outputToFile) ATH_MSG_INFO("Db dump to file activated");
211 if (m_crestCoolToFile) ATH_MSG_INFO("Crest or Cool dump to file activated");
212
213 ATH_MSG_INFO( "Service IOVDbSvc initialised successfully" );
214
216 return StatusCode::SUCCESS;
217}
BooleanProperty m_par_managePoolConnections
Definition IOVDbSvc.h:188
BooleanProperty m_crestCoolToFile
Definition IOVDbSvc.h:220
BooleanProperty m_outputToFile
Definition IOVDbSvc.h:219
BooleanProperty m_par_checklock
Definition IOVDbSvc.h:209
BooleanProperty m_par_manageConnections
Definition IOVDbSvc.h:186
StatusCode checkConfigConsistency() const
IntegerProperty m_par_maxNumPoolFiles
Definition IOVDbSvc.h:196
UnsignedIntegerProperty m_par_cacheAlign
Definition IOVDbSvc.h:205
IntegerProperty m_par_forceTimestamp
Definition IOVDbSvc.h:194
IntegerProperty m_par_cacheRun
Definition IOVDbSvc.h:200
StatusCode checkEventSel()
Definition IOVDbSvc.cxx:845
BooleanProperty m_par_onlineMode
Definition IOVDbSvc.h:207
StatusCode setupFolders()
Definition IOVDbSvc.cxx:906
IntegerProperty m_par_cacheTime
Definition IOVDbSvc.h:202
FloatProperty m_par_timeStampSlop
Definition IOVDbSvc.h:198
cool::ValidityKey m_iovslop
Definition IOVDbSvc.h:263
MsgStream & msg
Definition testRead.cxx:32

◆ io_finalize()

StatusCode IOVDbSvc::io_finalize ( )
finaloverride

Definition at line 228 of file IOVDbSvc.cxx.

228 {
229 ATH_MSG_DEBUG("I/O finalization...");
230 return StatusCode::SUCCESS;
231}

◆ io_reinit()

StatusCode IOVDbSvc::io_reinit ( )
finaloverride

Definition at line 220 of file IOVDbSvc.cxx.

220 {
221 ATH_MSG_DEBUG("I/O reinitialization...");
222 // PoolSvc clears all connections on IO_reinit - forget the stored contextId
223 m_poolSvcContext = -1;
224 return StatusCode::SUCCESS;
225}
int m_poolSvcContext
Definition IOVDbSvc.h:240

◆ loadAddresses()

StatusCode IOVDbSvc::loadAddresses ( StoreID::type storeID,
tadList & list )
overridevirtual

Get all new addresses from Provider for this Event.

Definition at line 410 of file IOVDbSvc.cxx.

410 {
411 // this method does nothing
412 return StatusCode::SUCCESS;
413}

◆ loadCaches()

StatusCode IOVDbSvc::loadCaches ( IOVDbConn * conn,
const IOVTime * time = nullptr )
private

Definition at line 1097 of file IOVDbSvc.cxx.

1097 {
1098 // load the caches for all folders using the given connection
1099 // so connection use is optimised
1100
1101 Gaudi::Guards::AuditorGuard auditor(std::string("loadCachesOverhead:")+conn->name(), auditorSvc(), "preLoadProxy");
1102
1103 ATH_MSG_DEBUG( "loadCaches: Begin for connection " << conn->name());
1104 // if global abort already set, load nothing
1105 if (m_abort) return StatusCode::FAILURE;
1106 bool access=false;
1107 StatusCode sc=StatusCode::SUCCESS;
1108 for (const auto & [name, folder] : m_foldermap) {
1109 if (folder->conn()!=conn) continue;
1110 cool::ValidityKey vkey=folder->iovTime(time==nullptr ? m_iovTime : *time);
1111 // protect against out of range times (timestamp -1 happened in FDR2)
1112 if (vkey>cool::ValidityKeyMax) {
1113 ATH_MSG_WARNING( "Requested validity key " << vkey << " is out of range, reset to 0" );
1114 vkey=0;
1115 }
1116 if (!folder->cacheValid(vkey) && !folder->dropped()) {
1117 access=true;
1118 {
1119 Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
1120 if (!folder->loadCache(vkey,m_par_cacheAlign,m_globalTag,m_par_onlineMode)) {
1121 ATH_MSG_ERROR( "Cache load (prefetch) failed for folder " << folder->folderName() );
1122 // remember the failure, but also load other folders on this connection
1123 // while it is open
1124 sc=StatusCode::FAILURE;
1125 }
1126 }
1127 }
1128 }
1129 // disconnect from database if we connected
1130 if (access && m_par_manageConnections) conn->setInactive();
1131 // if connection aborted, set overall abort so we do not waste time trying
1132 // to read data from other schema
1133 if (conn->aborted()) {
1134 m_abort=true;
1135 throw GaudiException("Connection " + conn->name() + " was aborted",
1136 "IOVDbSvc::loadCache()", StatusCode::FAILURE);
1137 }
1138 return sc;
1139}
static Double_t sc
bool m_abort
Definition IOVDbSvc.h:272
::StatusCode StatusCode
StatusCode definition for legacy code.
access(filename, mode)

◆ poolSvcContext()

int IOVDbSvc::poolSvcContext ( )
private

Definition at line 123 of file IOVDbSvc.cxx.

124{
125 if( m_poolSvcContext < 0 ) {
126 // Get context for POOL conditions files, and created an initial connection
128 m_poolSvcContext=m_h_poolSvc->getInputContext("Conditions", m_par_maxNumPoolFiles);
129 } else {
130 m_poolSvcContext=m_h_poolSvc->getInputContext("Conditions");
131 }
132 if( m_h_poolSvc->connect(pool::ITransaction::READ, m_poolSvcContext).isSuccess() ) {
133 ATH_MSG_INFO( "Opened read transaction for POOL PersistencySvc");
134 } else {
135 // We only emit info for failure to connect (for the moment? RDS 01/2008)
136 ATH_MSG_INFO( "Cannot connect to POOL PersistencySvc" );
137 }
138 }
139 return m_poolSvcContext;
140}
ServiceHandle< IPoolSvc > m_h_poolSvc
Definition IOVDbSvc.h:229

◆ postConditionsLoad()

void IOVDbSvc::postConditionsLoad ( )
overridevirtual

May be called once conditions are loaded to let IOVDbSvc release resources.

Definition at line 700 of file IOVDbSvc.cxx.

700 {
701 // Close any open POOL files after loding Conditions
702 ATH_MSG_DEBUG( "postConditionsLoad: m_par_managePoolConnections=" << m_par_managePoolConnections
703 << " m_poolPayloadRequested=" << m_poolPayloadRequested );
704
706 // reset POOL connection to close all open conditions POOL files
709 if( m_poolSvcContext ) {
710 if (m_h_poolSvc->disconnect(m_poolSvcContext).isSuccess()) {
711 ATH_MSG_DEBUG( "Successfully closed input POOL connections");
712 } else {
713 ATH_MSG_WARNING( "Unable to close input POOL connections" );
714 }
715 // reopen transaction
716 if (m_h_poolSvc->connect(pool::ITransaction::READ, m_poolSvcContext).isSuccess()) {
717 ATH_MSG_DEBUG("Reopend read transaction for POOL conditions input files" );
718 } else {
719 ATH_MSG_WARNING("Cannot reopen read transaction for POOL conditions input files");
720 }
721 }
722 }
723}

◆ preLoadAddresses()

StatusCode IOVDbSvc::preLoadAddresses ( StoreID::type storeID,
tadList & list )
overridevirtual

Get all addresses that the provider wants to preload in SG maps.

Definition at line 285 of file IOVDbSvc.cxx.

285 {
286 // Read information for folders and setup TADs
287 if (storeID!=StoreID::DETECTOR_STORE) return StatusCode::SUCCESS;
288 // Preloading of addresses should be done ONLY for detector store
289 ATH_MSG_DEBUG( "preLoadAddress: storeID -> " << storeID );
290
291 Athena::DBLock dblock;
292
293 // check File Level Meta Data of input, see if any requested folders are available there
294 SG::ConstIterator<IOVMetaDataContainer> cont;
295 SG::ConstIterator<IOVMetaDataContainer> contEnd;
296 if (m_h_metaDataStore->retrieve(cont,contEnd).isSuccess()) {
297 unsigned int ncontainers=0;
298 unsigned int nused=0;
299 for (;cont!=contEnd; ++cont) {
300 ++ncontainers;
301 const std::string& fname=cont->folderName();
302 // check if this folder is in list requested by IOVDbSvc
303 for (const auto & [name, folder] : m_foldermap) {
304 // take data from FLMD only if tag override is NOT set
305 if (folder->folderName()==fname && !(folder->tagOverride())) {
306 ATH_MSG_INFO( "Folder " << fname << " will be taken from file metadata" );
307 folder->useFileMetaData();
308 folder->setFolderDescription( cont->folderDescription() );
309 ++nused;
310 break;
311 }
312 }
313 }
314 ATH_MSG_INFO( "Found " << ncontainers << " metadata containers in input file, " << nused << " will be used");
315 } else {
316 ATH_MSG_DEBUG( "Could not retrieve IOVMetaDataContainer objects from MetaDataStore" );
317 }
318
319 // Remove folders which should only be read from file meta data, but
320 // were not found in the MetaDataStore
321
322 // Note: we cannot iterate and perform erase within the iteration
323 // because the iterator becomes invalid. So first collect the keys
324 // to erase in a first pass and then erase them.
325 std::vector<std::string> keysToDelete;
326 for (const auto & [name, folder] : m_foldermap) {
327 if (folder->fromMetaDataOnly() && !folder->readMeta()) {
328 ATH_MSG_INFO( "preLoadAddresses: Removing folder " << folder->folderName() <<
329 ". It should only be in the file meta data and was not found." );
330 keysToDelete.push_back(name);
331 }
332 }
333
334 for (auto & thisKey : keysToDelete) {
335 const auto fitr = m_foldermap.find(thisKey);
336 if (fitr != m_foldermap.end()) {
337 fitr->second->conn()->decUsage();
338 m_foldermap.erase(fitr);
339 } else {
340 ATH_MSG_ERROR( "preLoadAddresses: Could not find folder " << thisKey << " for removal" );
341 }
342 }
343
344
345 // loop over all folders, grouped by connection
346 // do metadata folders on first connection (default connection)
347 bool doMeta=true;
348 // do not close COOL connection until next one has been opened, this enables
349 // connection sharing in CORAL, so all COOL connections will use the same
350 // CORAL one (althugh they will each be given a separate session)
351 IOVDbConn* oldconn=nullptr;
352 for (const auto & pThisConnection : m_connections) {
353 if (pThisConnection->nFolders()>0 || doMeta) {
354 // loop over all folders using this connection
355 for (const auto & [name, folder] : m_foldermap) {
356 if (folder->conn()==pThisConnection.get() || (folder->conn()==nullptr && doMeta)) {
357 std::unique_ptr<SG::TransientAddress> tad =
359 if (oldconn!=pThisConnection.get()) {
360 // close old connection if appropriate
361 if (m_par_manageConnections && oldconn!=nullptr) oldconn->setInactive();
362 oldconn=pThisConnection.get();
363 }
364 if (tad==nullptr) {
365 ATH_MSG_ERROR( "preLoadFolder failed for folder " << folder->folderName() );
366 return StatusCode::FAILURE;
367 }
368 // for write-metadata folder, request data preload
369 if (folder->writeMeta()) {
370 if (m_h_IOVSvc->preLoadDataTAD(tad.get(),folder->eventStore()).isFailure()) {
371 ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
372 return StatusCode::FAILURE;
373 }
374 } else {
375 // for other folders, just preload TAD (not data)
376 if (m_h_IOVSvc->preLoadTAD(tad.get(), folder->eventStore()).isFailure()) {
377 ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
378 return StatusCode::FAILURE;
379 }
380 }
381 // Add TAD to Storegate
382 tlist.push_back(tad.release());
383 // check for IOV override
385 }
386 }
387 }
388 doMeta=false;
389 }
390 // close last connection
391 if (oldconn!=nullptr and m_par_manageConnections) oldconn->setInactive();
392
393 // some folder keys may have changed during preloadFolder due to use of
394 // <key> specification in folder description string
395 // build a new foldermap with the updated keys
396 FolderMap newmap;
397 for (auto & [name, folder] : m_foldermap) {
398 newmap[folder->key()]=std::move(folder);
399 }
400 m_foldermap=std::move(newmap);
401
402 // fill global and explicit folder tags into TagInfo
403 if (fillTagInfo().isFailure())
404 ATH_MSG_ERROR("Could not fill TagInfo object from preLoadAddresses" );
405
406 return StatusCode::SUCCESS;
407}
void setInactive()
ServiceHandle< StoreGateSvc > m_h_metaDataStore
Definition IOVDbSvc.h:226
StatusCode fillTagInfo()
std::map< std::string, std::unique_ptr< IOVDbFolder > > FolderMap
Definition IOVDbSvc.h:269
ServiceHandle< IIOVSvc > m_h_IOVSvc
Definition IOVDbSvc.h:223
@ DETECTOR_STORE
Definition StoreID.h:27

◆ processTagInfo()

StatusCode IOVDbSvc::processTagInfo ( )
overridevirtual

Process TagInfo.

Definition at line 748 of file IOVDbSvc.cxx.

748 {
749 // Processing of taginfo
750 // Set GlobalTag and any folder-specific overrides if given
751
752 // dump out contents of TagInfo
753 ATH_MSG_DEBUG( "Tags from input TagInfo:");
754 if( msg().level()>=MSG::DEBUG ) m_h_tagInfoMgr->printTags(msg());
755
756 // check IOVDbSvc GlobalTag, if not already set
757 if (m_globalTag.empty()) {
758 m_globalTag = m_h_tagInfoMgr->findTag("IOVDbGlobalTag");
759 if (!m_globalTag.empty()) ATH_MSG_INFO( "Global tag: " << m_globalTag<< " set from input file" );
761 }
762
763 // now check for tag overrides for specific folders
764 const ITagInfoMgr::NameTagPairVec& nameTagPairs = m_h_tagInfoMgr->getInputTags();
765 for (const auto & [theTagName, theTag]: nameTagPairs) {
766 // assume tags relating to conditions folders start with /
767 if (not theTagName.starts_with('/')) continue;
768 // check for folder(s) with this name in (key, ptr) pair
769 for (const auto & [name, folder]: m_foldermap) {
770 const std::string& ifname=folder->folderName();
771 if (ifname!=theTagName) continue;
772 // use an override from TagInfo only if there is not an explicit jo tag,
773 // and folder meta-data is not used, and there is no <noover/> spec,
774 // and no global tag set in job options
775 if (folder->joTag().empty() && !folder->readMeta() && !folder->noOverride() && m_par_globalTag.empty()) {
776 folder->setTagOverride(theTag,false);
777 ATH_MSG_INFO( "TagInfo override for tag " << theTag << " in folder " << ifname );
778 } else if (folder->joTag()!=theTag) {
779 const std::string_view tagTypeString=(folder->joTag().empty()) ? "hierarchical" : "jobOption";
780 ATH_MSG_INFO( "Ignoring inputfile TagInfo request for tag " << theTag << " in folder " << ifname<<" in favour of "<<tagTypeString);
781 }
782 }
783 }
784 return StatusCode::SUCCESS;
785}
static const Attributes_t empty
std::vector< NameTagPair > NameTagPairVec
Definition ITagInfoMgr.h:66

◆ setRange()

StatusCode IOVDbSvc::setRange ( const CLID & clid,
const std::string & dbKey,
const IOVRange & range,
const std::string & tag )
overridevirtual

Set range for a particular data object.

Definition at line 615 of file IOVDbSvc.cxx.

618 {
619 // this method does nothing
620 return StatusCode::SUCCESS;
621}

◆ setupFolders()

StatusCode IOVDbSvc::setupFolders ( )
private

Definition at line 906 of file IOVDbSvc.cxx.

906 {
907 // read the Folders joboptions and setup the folder list
908 // no wildcards are allowed
909
910 // getting the pairs: folder name - CREST tag name:
911 if (m_par_source == "CREST"){
912 m_cresttagmap.clear();
914 }
915
916 //1. Loop through folders
917 std::list<IOVDbParser> allFolderdata;
918 for (const auto & thisFolder : m_par_folders) {
919 ATH_MSG_DEBUG( "Setup folder " << thisFolder );
920 IOVDbParser folderdata(thisFolder,msg());
921 if (!folderdata.isValid()) {
922 ATH_MSG_FATAL("setupFolders: Folder setup string is invalid: " <<thisFolder);
923 return StatusCode::FAILURE;
924 }
925
926 allFolderdata.push_back(std::move(folderdata));
927 }
928
929 //2. Loop through overwrites:
930 // syntax for entries is <prefix>folderpath</prefix> <tag>value</tag>
931 // folderpath matches from left of folderName
932 // but if partial match, next character must be / so override for /Fred/Ji
933 // matches /Fred/Ji/A and /Fred/Ji but not /Fred/Jim
934
935 for (const auto & thisOverrideTag : m_par_overrideTags) {
936 IOVDbParser keys(thisOverrideTag,msg());
937 if (not keys.isValid()){
938 ATH_MSG_ERROR("An override tag was invalid: " << thisOverrideTag);
939 return StatusCode::FAILURE;
940 }
941 std::string prefix;
942 if (!keys.getKey("prefix","",prefix)) { // || !keys.getKey("tag","",tag)) {
943 ATH_MSG_ERROR( "Problem in overrideTag specification " <<thisOverrideTag );
944 return StatusCode::FAILURE;
945 }
946
947 for (auto& folderdata : allFolderdata) {
948 const std::string& ifname=folderdata.folderName();
949 if (ifname.starts_with(prefix) &&
950 (ifname.size()==prefix.size() || ifname[prefix.size()]=='/')) {
951 //Match!
952 folderdata.applyOverrides(keys,msg());
953 }
954 }
955 }
956
957 //3. Remove any duplicates:
958 std::list<IOVDbParser>::iterator it1=allFolderdata.begin();
959 std::list<IOVDbParser>::iterator it_e=allFolderdata.end();
960 for (;it1!=it_e;++it1) {
961 const IOVDbParser& folder1=*it1;
962 std::list<IOVDbParser>::iterator it2=it1;
963 ++it2;
964 while(it2!=it_e) {
965 const IOVDbParser& folder2=*it2;
966 if (folder1==folder2) {
967 it2=allFolderdata.erase(it2); //FIXME: Smarter distinction/reporting about same folder but different keys.
968 ATH_MSG_DEBUG( "Removing duplicate folder " << folder1.folderName());
969 } else {
970 ++it2;
971 //Catch suspicous cases:
972 if (folder1.folderName()==folder2.folderName()) {
973 ATH_MSG_WARNING( "Folder name appears twice: " << folder1.folderName() );
974 ATH_MSG_WARNING( folder1 << " vs " << folder2 );
975 }
976 }
977 }//end inner loop
978 }//end outer loop
979
980 //4.Set up folder map with cleaned folder list
981
982 bool crestError=false;
983 for (const auto& folderdata : allFolderdata) {
984 // find the connection specification first - db or dbConnection
985 // default is to use the 'default' connection
986 IOVDbConn* conn=nullptr;
987 std::string connstr;
988 if (folderdata.getKey("db","",connstr) ||
989 folderdata.getKey("dbConnection","",connstr)) {
990 // an explicit database name is specified
991 // check if it is already present in the existing connections
992 for (const auto & pThisConnection : m_connections) {
993 if (pThisConnection->name()==connstr) {
994 // found existing connection - use that
995 conn=pThisConnection.get();
996 break;
997 }
998 }
999 if (conn==nullptr) {
1000 // create new read-onlyconnection
1001 conn = m_connections.emplace_back(std::make_unique<IOVDbConn>(connstr,true,msg())).get();
1002 }
1003 } else {
1004 // no connection specified - use default if available
1005 if (!m_par_defaultConnection.empty()) {
1006 conn=m_connections[0].get();
1007 } else {
1008 ATH_MSG_FATAL( "Folder request " << folderdata.folderName() <<
1009 " gives no DB connection information and no default set" );
1010 return StatusCode::FAILURE;
1011 }
1012 }
1013
1014 // create the new folder, but only if a folder for this SG key has not
1015 // already been requested
1016
1017 std::string crestTag;
1018 if (m_par_source == "CREST"){
1019 crestTag = m_cresttagmap[folderdata.folderName()];
1020 if(crestTag.empty() && folderdata.folderName() != "/TagInfo") {
1021 ATH_MSG_FATAL( "GlobalTag "<< m_par_globalTag << " does not contain folder "
1022 << folderdata.folderName());
1023 crestError=true;
1024 continue;
1025 }
1026 }
1027
1028 auto folder=std::make_unique<IOVDbFolder>(conn,folderdata,msg(),&(*m_h_clidSvc), &(*m_h_metaDataTool),
1031 const std::string& key=folder->key();
1032 if (m_foldermap.find(key)==m_foldermap.end()) { //This check is too weak. For POOL-based folders, the SG key is in the folder description (not known at this point).
1033 m_foldermap[key]=std::move(folder);
1034 conn->incUsage();
1035 } else {
1036 ATH_MSG_ERROR( "Duplicate request for folder " <<
1037 folder->folderName() <<
1038 " associated to already requested Storegate key " << key );
1039 // clean up this duplicate request
1040 }
1041 }// end loop over folders
1042
1043 if(crestError)
1044 return StatusCode::FAILURE;
1045
1046 // check for folders to be written to metadata
1047 for (const auto & folderToWrite : m_par_foldersToWrite) {
1048 // match wildcard * at end of string only (i.e. /A/* matches /A/B, /A/C/D)
1049 std::string_view match=folderToWrite;
1050 std::string::size_type idx=folderToWrite.find('*');
1051 if (idx!=std::string::npos) {
1052 match=std::string_view(folderToWrite).substr(0,idx);
1053 }
1054 for (const auto & [name, folder] : m_foldermap) {
1055 if (folder->folderName().starts_with(match)) {
1056 folder->setWriteMeta();
1057 ATH_MSG_INFO( "Folder " << folder->folderName() << " will be written to file metadata" );
1058 }
1059 }//end loop over FolderMap
1060 }//end loop over m_par_foldersToWrite
1061 return StatusCode::SUCCESS;
1062}
static std::map< std::string, std::string > getGlobalTagMap(const std::string &crest_path, const std::string &globaltag)
PublicToolHandle< IIOVDbMetaDataTool > m_h_metaDataTool
Definition IOVDbSvc.h:230
Gaudi::Property< std::vector< std::string > > m_par_overrideTags
Definition IOVDbSvc.h:182
Gaudi::Property< std::vector< std::string > > m_par_folders
Definition IOVDbSvc.h:180
std::map< std::string, std::string > m_cresttagmap
Definition IOVDbSvc.h:215
ServiceHandle< IClassIDSvc > m_h_clidSvc
Definition IOVDbSvc.h:228
Gaudi::Property< std::vector< std::string > > m_par_foldersToWrite
Definition IOVDbSvc.h:184
StringProperty m_par_crestServer
Definition IOVDbSvc.h:213
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357

◆ signalBeginRun()

StatusCode IOVDbSvc::signalBeginRun ( const IOVTime & beginRunTime,
const EventContext & ctx )
overridevirtual

Set time for begin run.

Definition at line 624 of file IOVDbSvc.cxx.

626{
627 Athena::DBLock dblock;
628
629 // Begin run - set state and save time for later use
631 // Is this a different run compared to the previous call?
632 bool newRun = m_iovTime.isValid() && (m_iovTime.run() != beginRunTime.run());
633 m_iovTime=beginRunTime;
634 // For a MC event, the run number we need to use to look up the conditions
635 // may be different from that of the event itself. Override the run
636 // number with the conditions run number from the event context,
637 // if it is defined.
638 EventIDBase::number_type conditionsRun =
640 if (conditionsRun != EventIDBase::UNDEFNUM) {
641 m_iovTime.setRunEvent (conditionsRun, m_iovTime.event());
642 }
643
644 ATH_MSG_DEBUG( "signalBeginRun> begin run time " << m_iovTime);
645 if (!m_par_onlineMode) {
646 return StatusCode::SUCCESS;
647 }
648
649 // ONLINE mode: allow adding of new calibration constants between runs
650 if (!newRun) {
651 ATH_MSG_DEBUG( "Same run as previous signalBeginRun call. Skipping re-loading of folders..." );
652 return StatusCode::SUCCESS;
653 }
654
655 // all other stuff is event based so happens after this.
656 // this is before first event of each run
657 ATH_MSG_DEBUG( "In online mode will recheck ... " );
658 ATH_MSG_DEBUG( "First reload PoolCataloge ... " );
659
660 pool::IFileCatalog* catalog ATLAS_THREAD_SAFE = // we are not within the event loop yet
661 const_cast<pool::IFileCatalog*>(m_h_poolSvc->catalog());
662 catalog->commit();
663 catalog->start();
664
665 for (const auto & pThisConnection : m_connections){
666 // only access connections which are actually in use - avoids waking up
667 // the default DB connection if it is not being used
668 if (pThisConnection->nFolders()>0) {
669 //request for database activates connection
670 cool::IDatabasePtr dbconn=pThisConnection->getCoolDb();
671 if (dbconn.get()==nullptr) {
672 ATH_MSG_FATAL( "Conditions database connection " << pThisConnection->name() << " cannot be opened - STOP" );
673 return StatusCode::FAILURE;
674 }
675 for (const auto & [name, folder]: m_foldermap) {
676 if (folder->conn()!=pThisConnection.get()) continue;
677 folder->printCache();
678 cool::ValidityKey vkey=folder->iovTime(m_iovTime);
679 {
680 Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
681 if (!folder->loadCacheIfDbChanged(vkey, m_globalTag, dbconn, m_h_IOVSvc)) {
682 ATH_MSG_ERROR( "Problem RELOADING: " << folder->folderName());
683 return StatusCode::FAILURE;
684 }
685 }
686 folder->printCache();
687 }
688 }
689 if (m_par_manageConnections) pThisConnection->setInactive();
690 }
691 return StatusCode::SUCCESS;
692}
#define ATLAS_THREAD_SAFE
EventIDBase::number_type conditionsRun() const
uint32_t run() const noexcept
Definition IOVTime.h:105
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.

◆ signalEndProxyPreload()

void IOVDbSvc::signalEndProxyPreload ( )
overridevirtual

Signal that callback has been fired.

Definition at line 695 of file IOVDbSvc.cxx.

695 {
696 // this method does nothing
697}

◆ updateAddress()

StatusCode IOVDbSvc::updateAddress ( StoreID::type storeID,
SG::TransientAddress * tad,
const EventContext & ctx )
overridevirtual

Update a transient Address.

Definition at line 416 of file IOVDbSvc.cxx.

418{
419 // Provide TAD and associated range, actually reading the conditions data
420
421 // Read information for folders and setup TADs
422 if (storeID!=StoreID::DETECTOR_STORE) return StatusCode::FAILURE;
423 Gaudi::Guards::AuditorGuard auditor(std::string("UpdateAddr::")+(tad->name().empty() ? "anonymous" : tad->name()),
424 auditorSvc(), "preLoadProxy");
425
426 IOVTime iovTime{m_iovTime};
427 IOVRange range;
428 std::unique_ptr<IOpaqueAddress> address;
429
430 // first check if this key is managed by IOVDbSvc
431 // return FAILURE if not - this allows other AddressProviders to be
432 // asked for the TAD
433 const std::string& key=tad->name();
434 const auto fitr=m_foldermap.find(key);
435 if (fitr==m_foldermap.end()) {
437 "updateAddress cannot find description for TAD " << key );
438 return StatusCode::FAILURE;
439 }
440 const auto& folder=fitr->second;
441 if (folder->clid()!=tad->clID()) {
442 ATH_MSG_VERBOSE( "CLID for TAD " << key << " is " << tad->clID()
443 << " but expecting " << folder->clid() );
444
445 return StatusCode::FAILURE;
446 }
447
448 // IOVDbSvc will satisfy the request, using already found folder
449 // now determine the current IOVTime
450 if (m_state==IOVDbSvc::INITIALIZATION && !m_iovTime.isValid()) {
451 ATH_MSG_DEBUG( "updateAddress: in initialisation phase and no iovTime defined" );
452 return::StatusCode::SUCCESS;
453 }
455 // determine iovTime from eventID in the event context
456 const EventIDBase* evid = EventIDFromStore( m_h_sgSvc );
457 if( evid ) {
458 iovTime.setRunEvent( evid->run_number(), evid->lumi_block()) ;
459 // save both seconds and ns offset for timestamp
460 uint64_t nsTime = evid->time_stamp() *1000000000LL;
461 nsTime += evid->time_stamp_ns_offset();
462 iovTime.setTimestamp(nsTime);
463 m_iovTime = iovTime;
464 ATH_MSG_DEBUG( "updateAddress - using iovTime from EventInfo: " << iovTime);
465 } else {
466 // failed to get event info - just return success
467 ATH_MSG_DEBUG( "Could not get event - initialise phase");
468 return StatusCode::SUCCESS;
469 }
470 } else {
471 ATH_MSG_DEBUG("updateAddress: using iovTime from init/beginRun: " << iovTime);
472 }
473
474
475
476 // obtain the validity key for this folder (includes overrides)
477 cool::ValidityKey vkey=folder->iovTime(iovTime);
478 {
479 // The dblock is currently abused to also protect the cache in the IOVDbFolders.
480 // This global lock may give rise to deadlocks between the dblock and the internal lock
481 // of the SGImplSvc. The deadlock may arise if the order of the initial call to IOVDbSvc
482 // and SGImplSvc are different, because the two services call each other.
483 // A problem was observed when SG::DataProxy::isValidAddress first called IOVDbSvc::updateAddress
484 // which called IOVSvc::setRange then SGImplSvc::proxy, and at the same time
485 // StoreGateSvc::contains called first SGImplSvc::proxy which then called IOVDbSvc::updateAddress.
486 // This problem is mitigated by limiting the scope of the dblock here.
487 Athena::DBLock dblock;
488 ATH_MSG_DEBUG("Validity key "<<vkey);
489 if (!folder->readMeta() && !folder->cacheValid(vkey)) {
490 // mark this folder as not-dropped so cache-read will succeed
491 folder->setDropped(false);
492 // reload cache for this folder (and all others sharing this DB connection)
493 ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName());
494 if (loadCaches(folder->conn()).isFailure()) {
495 ATH_MSG_ERROR( "Cache load failed for at least one folder from " << folder->conn()->name()
496 << ". You may see errors from other folders sharing the same connection." );
497 return StatusCode::FAILURE;
498 }
499 }
500
501 // data should now be in cache
502 // setup address and range
503 {
504 Gaudi::Guards::AuditorGuard auditor(std::string("FldrSetup:")+(tad->name().empty() ? "anonymous" : tad->name()),
505 auditorSvc(), "preLoadProxy");
506 if (!folder->getAddress(vkey,&(*m_h_persSvc),poolSvcContext(),address,
507 range,m_poolPayloadRequested)) {
508 ATH_MSG_ERROR( "getAddress failed for folder " << folder->folderName() );
509 return StatusCode::FAILURE;
510 }
511 }
512 // reduce minimum IOV of timestamp folders to avoid 'thrashing'
513 // due to events slightly out of order in HLT
514 if (folder->timeStamp()) {
515 cool::ValidityKey start=range.start().timestamp();
516 if (start>m_iovslop) start-=m_iovslop;
517 range=IOVRange(IOVTime(start),range.stop());
518 }
519 }
520
521 // Pass range onto IOVSvc
522 if (m_h_IOVSvc->setRange(tad->clID(),tad->name(),
523 range,folder->eventStore()).isFailure()) {
524 ATH_MSG_ERROR( "setRange failed for folder " << folder->folderName() );
525 return StatusCode::FAILURE;
526 }
527 tad->setAddress(address.release());
528 return StatusCode::SUCCESS;
529}
const EventIDBase * EventIDFromStore(IProxyDict *store)
Retrieve the EventID from EventContext saved in store STORE.
void setRunEvent(uint32_t run, uint32_t event) noexcept
Definition IOVTime.cxx:96
CLID clID() const
Retrieve string key:
const std::string & name() const
Get the primary (hashed) SG key.
void setAddress(CxxUtils::RefCountedPtr< IOpaqueAddress > pAddress)
Retrieve primary clid.

Member Data Documentation

◆ m_abort

bool IOVDbSvc::m_abort {false}
private

Definition at line 272 of file IOVDbSvc.h.

272{false};

◆ m_connections

std::vector<std::unique_ptr<IOVDbConn> > IOVDbSvc::m_connections
private

Definition at line 266 of file IOVDbSvc.h.

◆ m_crestCoolToFile

BooleanProperty IOVDbSvc::m_crestCoolToFile {this,"CrestCoolToFile",false,"output to file crest or cool data in the same format for debugging purposes"}
private

Definition at line 220 of file IOVDbSvc.h.

220{this,"CrestCoolToFile",false,"output to file crest or cool data in the same format for debugging purposes"};

◆ m_cresttagmap

std::map<std::string, std::string> IOVDbSvc::m_cresttagmap
private

Definition at line 215 of file IOVDbSvc.h.

◆ m_foldermap

FolderMap IOVDbSvc::m_foldermap
private

Definition at line 270 of file IOVDbSvc.h.

◆ m_globalTag

std::string IOVDbSvc::m_globalTag {}
private

Definition at line 260 of file IOVDbSvc.h.

260{};

◆ m_h_clidSvc

ServiceHandle<IClassIDSvc> IOVDbSvc::m_h_clidSvc {this,"ClassIDSvc","ClassIDSvc"}
private

Definition at line 228 of file IOVDbSvc.h.

228{this,"ClassIDSvc","ClassIDSvc"};

◆ m_h_detStore

ServiceHandle<StoreGateSvc> IOVDbSvc::m_h_detStore {this,"DetectorStore","DetectorStore"}
private

Definition at line 225 of file IOVDbSvc.h.

225{this,"DetectorStore","DetectorStore"};

◆ m_h_IOVSvc

ServiceHandle<IIOVSvc> IOVDbSvc::m_h_IOVSvc {this,"IOVSvc","IOVSvc"}
private

Definition at line 223 of file IOVDbSvc.h.

223{this,"IOVSvc","IOVSvc"};

◆ m_h_metaDataStore

ServiceHandle<StoreGateSvc> IOVDbSvc::m_h_metaDataStore {this,"MetaDataStore","StoreGateSvc/MetaDataStore"}
private

Definition at line 226 of file IOVDbSvc.h.

226{this,"MetaDataStore","StoreGateSvc/MetaDataStore"};

◆ m_h_metaDataTool

PublicToolHandle<IIOVDbMetaDataTool> IOVDbSvc::m_h_metaDataTool {this,"IOVDbMetaDataTool","IOVDbMetaDataTool"}
private

Definition at line 230 of file IOVDbSvc.h.

230{this,"IOVDbMetaDataTool","IOVDbMetaDataTool"};

◆ m_h_persSvc

ServiceHandle<IAddressCreator> IOVDbSvc::m_h_persSvc {this,"EventPersistencySvc","EventPersistencySvc"}
private

Definition at line 227 of file IOVDbSvc.h.

227{this,"EventPersistencySvc","EventPersistencySvc"};

◆ m_h_poolSvc

ServiceHandle<IPoolSvc> IOVDbSvc::m_h_poolSvc {this,"PoolSvc","PoolSvc"}
private

Definition at line 229 of file IOVDbSvc.h.

229{this,"PoolSvc","PoolSvc"};

◆ m_h_sgSvc

ServiceHandle<StoreGateSvc> IOVDbSvc::m_h_sgSvc {this,"StoreGateSvc","StoreGateSvc"}
private

Definition at line 224 of file IOVDbSvc.h.

224{this,"StoreGateSvc","StoreGateSvc"};

◆ m_h_tagInfoMgr

ServiceHandle<ITagInfoMgr> IOVDbSvc::m_h_tagInfoMgr {this,"TagInfoMgr","TagInfoMgr"}
private

Definition at line 231 of file IOVDbSvc.h.

231{this,"TagInfoMgr","TagInfoMgr"};

◆ m_iovslop

cool::ValidityKey IOVDbSvc::m_iovslop {}
private

Definition at line 263 of file IOVDbSvc.h.

263{};

◆ m_iovTime

IOVTime IOVDbSvc::m_iovTime {}
private

Definition at line 257 of file IOVDbSvc.h.

257{};

◆ m_outputToFile

BooleanProperty IOVDbSvc::m_outputToFile {this,"OutputToFile",false,"output to file for debugging purposes"}
private

Definition at line 219 of file IOVDbSvc.h.

219{this,"OutputToFile",false,"output to file for debugging purposes"};

◆ m_par_cacheAlign

UnsignedIntegerProperty IOVDbSvc::m_par_cacheAlign {this,"CacheAlign",0,"cache alignment - divide cache into N slices and align queries on slice"}
private

Definition at line 205 of file IOVDbSvc.h.

205{this,"CacheAlign",0,"cache alignment - divide cache into N slices and align queries on slice"};

◆ m_par_cacheRun

IntegerProperty IOVDbSvc::m_par_cacheRun {this,"CacheRun",0,"force larger numbers of runs to be cached"}
private

Definition at line 200 of file IOVDbSvc.h.

200{this,"CacheRun",0,"force larger numbers of runs to be cached"};

◆ m_par_cacheTime

IntegerProperty IOVDbSvc::m_par_cacheTime {this,"CacheTime",0,"force larger timeranges to be cached (seconds)"}
private

Definition at line 202 of file IOVDbSvc.h.

202{this,"CacheTime",0,"force larger timeranges to be cached (seconds)"};

◆ m_par_checklock

BooleanProperty IOVDbSvc::m_par_checklock {this,"CheckLock",false,"check to ensure global/HVS tags are locked (for production)"}
private

Definition at line 209 of file IOVDbSvc.h.

209{this,"CheckLock",false,"check to ensure global/HVS tags are locked (for production)"};

◆ m_par_crestServer

StringProperty IOVDbSvc::m_par_crestServer {this,"crestServer","https://crest.cern.ch","CREST URL with the port number as a string (default https://crest.cern.ch)"}
private

Definition at line 213 of file IOVDbSvc.h.

213{this,"crestServer","https://crest.cern.ch","CREST URL with the port number as a string (default https://crest.cern.ch)"};

◆ m_par_dbinst

Gaudi::Property<std::string> IOVDbSvc::m_par_dbinst {this,"DBInstance","","Database instance (like OFLP200)"}
private

Definition at line 178 of file IOVDbSvc.h.

178{this,"DBInstance","","Database instance (like OFLP200)"};

◆ m_par_defaultConnection

Gaudi::Property<std::string> IOVDbSvc::m_par_defaultConnection {this,"dbConnection","sqlite://;schema=cooldummy.db;dbname=OFLP200","default DB connection string"}
private

Definition at line 174 of file IOVDbSvc.h.

174{this,"dbConnection","sqlite://;schema=cooldummy.db;dbname=OFLP200","default DB connection string"};

◆ m_par_folders

Gaudi::Property<std::vector<std::string> > IOVDbSvc::m_par_folders {this,"Folders",{},"List of database folders to preload","OrderedSet<std::string>"}
private

Definition at line 180 of file IOVDbSvc.h.

180{this,"Folders",{},"List of database folders to preload","OrderedSet<std::string>"};

◆ m_par_foldersToWrite

Gaudi::Property<std::vector<std::string> > IOVDbSvc::m_par_foldersToWrite {this,"FoldersToMetaData",{},"list of folders to write to file meta data","OrderedSet<std::string>"}
private

Definition at line 184 of file IOVDbSvc.h.

184{this,"FoldersToMetaData",{},"list of folders to write to file meta data","OrderedSet<std::string>"};

◆ m_par_forceLumiblockNumber

IntegerProperty IOVDbSvc::m_par_forceLumiblockNumber {this,"forceLumiblockNumber",0,"globally force LB-number (default: no force)"}
private

Definition at line 192 of file IOVDbSvc.h.

192{this,"forceLumiblockNumber",0,"globally force LB-number (default: no force)"};

◆ m_par_forceRunNumber

IntegerProperty IOVDbSvc::m_par_forceRunNumber {this,"forceRunNumber",0,"globally force run-number (default: no force)"}
private

Definition at line 190 of file IOVDbSvc.h.

190{this,"forceRunNumber",0,"globally force run-number (default: no force)"};

◆ m_par_forceTimestamp

IntegerProperty IOVDbSvc::m_par_forceTimestamp {this,"forceTimeStamp",0,"globally force time-stamp (default: no force)"}
private

Definition at line 194 of file IOVDbSvc.h.

194{this,"forceTimeStamp",0,"globally force time-stamp (default: no force)"};

◆ m_par_format

StringProperty IOVDbSvc::m_par_format {this,"Format",{},"Format of data; default is empty string (default for a given source)"}
private

Definition at line 217 of file IOVDbSvc.h.

217{this,"Format",{},"Format of data; default is empty string (default for a given source)"};

◆ m_par_globalTag

Gaudi::Property<std::string> IOVDbSvc::m_par_globalTag {this,"GlobalTag","","Global database tag"}
private

Definition at line 176 of file IOVDbSvc.h.

176{this,"GlobalTag","","Global database tag"};

◆ m_par_manageConnections

BooleanProperty IOVDbSvc::m_par_manageConnections {this,"ManageConnections",true,"flag to trigger the connections management"}
private

Definition at line 186 of file IOVDbSvc.h.

186{this,"ManageConnections",true,"flag to trigger the connections management"};

◆ m_par_managePoolConnections

BooleanProperty IOVDbSvc::m_par_managePoolConnections {this,"ManagePoolConnections",true,"flag to manage pool connections"}
private

Definition at line 188 of file IOVDbSvc.h.

188{this,"ManagePoolConnections",true,"flag to manage pool connections"};

◆ m_par_maxNumPoolFiles

IntegerProperty IOVDbSvc::m_par_maxNumPoolFiles {this,"MaxPoolFilesOpen",5,"max number of pool files open allowed (0 means no limit)"}
private

Definition at line 196 of file IOVDbSvc.h.

196{this,"MaxPoolFilesOpen",5,"max number of pool files open allowed (0 means no limit)"};

◆ m_par_onlineMode

BooleanProperty IOVDbSvc::m_par_onlineMode {this,"OnlineMode",false,"online mode flag to ignore missing channels outside cache range"}
private

Definition at line 207 of file IOVDbSvc.h.

207{this,"OnlineMode",false,"online mode flag to ignore missing channels outside cache range"};

◆ m_par_overrideTags

Gaudi::Property<std::vector<std::string> > IOVDbSvc::m_par_overrideTags {this,"overrideTags",{},"List of xml-modifiers for folders like <prefix>/My/Folder</prefix><tag>MyFolderTag</tag>","OrderedSet<std::string>"}
private

Definition at line 182 of file IOVDbSvc.h.

182{this,"overrideTags",{},"List of xml-modifiers for folders like <prefix>/My/Folder</prefix><tag>MyFolderTag</tag>","OrderedSet<std::string>"};

◆ m_par_source

StringProperty IOVDbSvc::m_par_source {this,"Source","COOL_DATABASE","source of data as a string (default COOL_DATABASE)"}
private

Definition at line 211 of file IOVDbSvc.h.

211{this,"Source","COOL_DATABASE","source of data as a string (default COOL_DATABASE)"};

◆ m_par_timeStampSlop

FloatProperty IOVDbSvc::m_par_timeStampSlop {this,"TimeStampSlop",0.0,"backdata timestamp IOVs by this many seconds"}
private

Definition at line 198 of file IOVDbSvc.h.

198{this,"TimeStampSlop",0.0,"backdata timestamp IOVs by this many seconds"};

◆ m_poolPayloadRequested

bool IOVDbSvc::m_poolPayloadRequested {false}
private

Definition at line 236 of file IOVDbSvc.h.

236{false};

◆ m_poolSvcContext

int IOVDbSvc::m_poolSvcContext {-1}
private

Definition at line 240 of file IOVDbSvc.h.

240{-1};

◆ m_state

IOVDbSvc_state IOVDbSvc::m_state {INITIALIZATION}
private

Definition at line 254 of file IOVDbSvc.h.


The documentation for this class was generated from the following files: