ATLAS Offline Software
Loading...
Searching...
No Matches
IOVDbSvc.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5// IOVDbSvc.cxx
6// Re-implementation of Athena IOVDbSvc
7// Richard Hawkijngs, started 23/11/08
8// based on earlier code by RD Schaffer, Antoine Perus and RH
9
12#include "Gaudi/Interfaces/IOptionsSvc.h"
13#include "GaudiKernel/IIncidentSvc.h"
14#include "GaudiKernel/Guards.h"
15#include "GaudiKernel/IOpaqueAddress.h"
16#include "GaudiKernel/IProperty.h"
17#include "GaudiKernel/IIoComponentMgr.h"
23#include "DBLock/DBLock.h"
25
26#include "IOVDbParser.h"
27#include "IOVDbFolder.h"
28#include "IOVDbSvc.h"
29#include "CoralCrestManager.h"
30
31#include <algorithm>
32#include <list>
33#include <utility>
34
35// helper function for getting jobopt properties
36namespace {
37 bool
38 refersToConditionsFolder(const ITagInfoMgr::NameTagPair & thisPair){
39 return thisPair.first.front() == '/';
40 }
41
42
43// Wrap a cool IDatabase with a DBLock.
44class LockedDatabase
45 : public cool::IDatabase
46{
47public:
48 LockedDatabase (cool::IDatabasePtr dbptr,
49 const Athena::DBLock& dblock);
50 virtual ~LockedDatabase();
51
52 virtual const cool::DatabaseId& databaseId() const override
53 { return m_dbptr->databaseId(); }
54
55 virtual const cool::IRecord& databaseAttributes() const override
56 { return m_dbptr->databaseAttributes(); }
57
58 virtual cool::IFolderSetPtr createFolderSet
59 ( const std::string& fullPath,
60 const std::string& description = "",
61 bool createParents = false ) override
62 { return m_dbptr->createFolderSet (fullPath, description, createParents); }
63
64 virtual bool existsFolderSet( const std::string& folderSetName ) override
65 { return m_dbptr->existsFolderSet (folderSetName); }
66
67 virtual cool::IFolderSetPtr getFolderSet( const std::string& fullPath ) override
68 { return m_dbptr->getFolderSet (fullPath); }
69
70 virtual cool::IFolderPtr createFolder
71 ( const std::string& fullPath,
72 const cool::IFolderSpecification& folderSpec,
73 const std::string& description = "",
74 bool createParents = false ) override
75 { return m_dbptr->createFolder (fullPath, folderSpec, description, createParents); }
76
77 virtual bool existsFolder( const std::string& fullPath ) override
78 { return m_dbptr->existsFolder (fullPath); }
79
80 virtual cool::IFolderPtr getFolder( const std::string& fullPath ) override
81 { return m_dbptr->getFolder (fullPath); }
82
83 virtual const std::vector<std::string> listAllNodes( bool ascending = true ) override
84 { return m_dbptr->listAllNodes (ascending); }
85
86 virtual bool dropNode( const std::string& fullPath ) override
87 { return m_dbptr->dropNode (fullPath); }
88
89 virtual bool existsTag( const std::string& tagName ) const override
90 { return m_dbptr->existsTag (tagName); }
91
92 virtual cool::IHvsNode::Type tagNameScope( const std::string& tagName ) const override
93 { return m_dbptr->tagNameScope (tagName); }
94
95 virtual const std::vector<std::string>
96 taggedNodes( const std::string& tagName ) const override
97 { return m_dbptr->taggedNodes (tagName); }
98
99 virtual bool isOpen() const override
100 { return m_dbptr->isOpen(); }
101
102 virtual void openDatabase() override
103 { return m_dbptr->openDatabase(); }
104
105 virtual void closeDatabase() override
106 { return m_dbptr->closeDatabase(); }
107
108 virtual const std::string& databaseName() const override
109 { return m_dbptr->databaseName(); }
110
111#ifdef COOL400TX
113 virtual ITransactionPtr startTransaction() override
114 { return m_dbptr->startTransaction(); }
115#endif
116
117
118private:
119 cool::IDatabasePtr m_dbptr;
120 Athena::DBLock m_dblock;
121};
122
123
124LockedDatabase::LockedDatabase (cool::IDatabasePtr dbptr,
125 const Athena::DBLock& dblock)
126 : m_dbptr (std::move(dbptr)),
127 m_dblock (dblock)
128{
129}
130
131
132LockedDatabase::~LockedDatabase()
133= default;
134
135
136} // anonymous namespace
137
138
139IOVDbSvc::~IOVDbSvc() = default;
140
142{
143 if( m_poolSvcContext < 0 ) {
144 // Get context for POOL conditions files, and created an initial connection
146 m_poolSvcContext=m_h_poolSvc->getInputContext("Conditions", m_par_maxNumPoolFiles);
147 } else {
148 m_poolSvcContext=m_h_poolSvc->getInputContext("Conditions");
149 }
150 if( m_h_poolSvc->connect(pool::ITransaction::READ, m_poolSvcContext).isSuccess() ) {
151 ATH_MSG_INFO( "Opened read transaction for POOL PersistencySvc");
152 } else {
153 // We only emit info for failure to connect (for the moment? RDS 01/2008)
154 ATH_MSG_INFO( "Cannot connect to POOL PersistencySvc" );
155 }
156 }
157 return m_poolSvcContext;
158}
159
161 if (StatusCode::SUCCESS!=AthService::initialize()) return StatusCode::FAILURE;
162 // subscribe to events
163 ServiceHandle<IIncidentSvc> incSvc("IncidentSvc",name());
164 if (StatusCode::SUCCESS!=incSvc.retrieve()) {
165 ATH_MSG_ERROR( "Unable to get the IncidentSvc" );
166 return StatusCode::FAILURE;
167 }
168 long int pri=100;
169 incSvc->addListener( this, "BeginEvent", pri );
170 incSvc->addListener( this, "StoreCleared", pri ); // for SP Athena
171 incSvc->addListener( this, IncidentType::EndProcessing, pri ); // for MT Athena
172
173 // Register this service for 'I/O' events
174 ServiceHandle<IIoComponentMgr> iomgr("IoComponentMgr", name());
175 if (!iomgr.retrieve().isSuccess()) {
176 ATH_MSG_FATAL("Could not retrieve IoComponentMgr !");
177 return(StatusCode::FAILURE);
178 }
179 if (!iomgr->io_register(this).isSuccess()) {
180 ATH_MSG_FATAL("Could not register myself with the IoComponentMgr !");
181 return(StatusCode::FAILURE);
182 }
183 // print warnings/info depending on state of job options
185 ATH_MSG_INFO( "COOL connection management disabled - connections kept open throughout job" );
187 ATH_MSG_INFO( "POOL file connection management disabled - files kept open throught job" );
188 if (m_par_maxNumPoolFiles.value() > 0)
189 ATH_MSG_INFO( "Only " << m_par_maxNumPoolFiles.value() << " POOL conditions files will be open at once" );
190 if (m_par_forceRunNumber.value() > 0 || m_par_forceLumiblockNumber.value() > 0)
191 ATH_MSG_WARNING( "Global run/LB number forced to be [" <<
192 m_par_forceRunNumber.value() << "," << m_par_forceLumiblockNumber.value() << "]" );
193 if (m_par_forceTimestamp.value() > 0)
194 ATH_MSG_WARNING( "Global timestamp forced to be " <<
195 m_par_forceTimestamp.value() );
196 if (m_par_cacheRun.value() > 0)
197 ATH_MSG_INFO( "Run-LB data will be cached in groups of " <<
198 m_par_cacheRun.value() << " runs" );
199 if (m_par_cacheTime.value() > 0)
200 ATH_MSG_INFO( "Timestamp data will be cached in groups of " << m_par_cacheTime.value() << " seconds" );
201 if (m_par_cacheAlign > 0)
202 ATH_MSG_INFO( "Cache alignment will be done in " << m_par_cacheAlign.value() << " slices" );
203 if (m_par_onlineMode)
204 ATH_MSG_INFO( "Online mode ignoring potential missing channels outside cache" );
205 if (m_par_checklock)
206 ATH_MSG_INFO( "Tags will be required to be locked");
207
208 // make sure iovTime is undefined
209 m_iovTime.reset();
210
211 // extract information from EventSelector for run/LB/time overrides
212 if (StatusCode::SUCCESS!=checkEventSel()) return StatusCode::FAILURE;
213
214 // initialise default connection
215 if (!m_par_defaultConnection.empty()) {
216 // default connection is readonly if no : in name (i.e. logical conn)
217 bool readonly=(m_par_defaultConnection.value().find(':')==std::string::npos);
218 m_connections.push_back(new IOVDbConn(m_par_defaultConnection,readonly,msg()));
219 }
220
221 // set time of timestampslop in nanoseconds
222 m_iovslop=static_cast<cool::ValidityKey>(m_par_timeStampSlop*1.E9);
223
224 // check for global tag in jobopt, which will override anything in input file
225 if (!m_par_globalTag.empty()) {
227 ATH_MSG_INFO( "Global tag: " << m_par_globalTag.value() << " set from joboptions" );
228 }
229
230 // setup folders and process tag overrides
231 if (StatusCode::SUCCESS!=setupFolders()) return StatusCode::FAILURE;
232
233 // Set state to initialize
235 ATH_MSG_INFO( "Initialised with " << m_connections.size() <<
236 " connections and " << m_foldermap.size() << " folders" );
237 if (m_outputToFile.value()) ATH_MSG_INFO("Db dump to file activated");
238 if (m_crestCoolToFile.value())ATH_MSG_INFO("Crest or Cool dump to file activated");
239 ATH_MSG_INFO( "Service IOVDbSvc initialised successfully" );
240
242 return StatusCode::SUCCESS;
243}
244
245
247 ATH_MSG_DEBUG("I/O reinitialization...");
248 // PoolSvc clears all connections on IO_reinit - forget the stored contextId
249 m_poolSvcContext = -1;
250 return(StatusCode::SUCCESS);
251}
252
254 ATH_MSG_DEBUG("I/O finalization...");
255 return(StatusCode::SUCCESS);
256}
257
258StatusCode IOVDbSvc::finalize() {
259 // summarise and delete folders, adding total read from COOL
260 unsigned long long nread=0;
261 float readtime=0.;
262 // accumulate a map of readtime by connection
263 typedef std::map<IOVDbConn*,float> CTMap;
264 CTMap ctmap;
265 for (const auto & namePtrPair : m_foldermap) {
266 IOVDbFolder* folder=namePtrPair.second;
267 folder->summary();
268 nread+=folder->bytesRead();
269 const float& fread=folder->readTime();
270 readtime+=fread;
271 IOVDbConn* cptr=folder->conn();
272 CTMap::iterator citr=ctmap.find(cptr);
273 if (citr!=ctmap.end()) {
274 (citr->second)+=fread;
275 } else {
276 ctmap.insert(CTMap::value_type(cptr,fread));
277 }
278 delete folder;
279 }
280 ATH_MSG_INFO( "Total payload read from IOVDb: " << nread << " bytes in (( " << std::fixed << std::setw(9) << std::setprecision(2) <<
281 readtime << " ))s" );
282
283 // close and delete connections, printing time in each one
284 for (auto & pThisConnection : m_connections) {
285 float fread=0;
286 CTMap::iterator citr=ctmap.find(pThisConnection);
287 if (citr!=ctmap.end()) fread=citr->second;
288 pThisConnection->setInactive();
289 pThisConnection->summary(fread);
290 delete pThisConnection;
291 }
292 // finally remove the msg svc
293 //delete m_log;
294 return AthService::finalize();
295}
296
297cool::IDatabasePtr IOVDbSvc::getDatabase(bool readOnly) {
298 // get default database connection
299 cool::IDatabasePtr dbconn;
300 if (m_par_defaultConnection.empty() || m_connections.empty()) {
301 ATH_MSG_INFO( "No default COOL database connection is available");
302 dbconn.reset();
303 } else {
304 Athena::DBLock dblock;
305 if (m_connections[0]->isReadOnly()!=readOnly) {
306 ATH_MSG_INFO("Changing state of default connection to readonly=" << readOnly );
307 m_connections[0]->setReadOnly(readOnly);
308 }
309 dbconn = std::make_shared<LockedDatabase> (m_connections[0]->getCoolDb(),
310 dblock);
311 }
312 return dbconn;
313}
314
316 // Read information for folders and setup TADs
317 if (storeID!=StoreID::DETECTOR_STORE) return StatusCode::SUCCESS;
318 // Preloading of addresses should be done ONLY for detector store
319 ATH_MSG_DEBUG( "preLoadAddress: storeID -> " << storeID );
320
321 Athena::DBLock dblock;
322
323 // check File Level Meta Data of input, see if any requested folders are available there
326 if (StatusCode::SUCCESS==m_h_metaDataStore->retrieve(cont,contEnd)) {
327 unsigned int ncontainers=0;
328 unsigned int nused=0;
329 for (;cont!=contEnd; ++cont) {
330 ++ncontainers;
331 const std::string& fname=cont->folderName();
332 // check if this folder is in list requested by IOVDbSvc
333 for (const auto & thisNamePtrPair : m_foldermap) {
334 IOVDbFolder* folder = thisNamePtrPair.second;
335 // take data from FLMD only if tag override is NOT set
336 if (folder->folderName()==fname && !(folder->tagOverride())) {
337 ATH_MSG_INFO( "Folder " << fname << " will be taken from file metadata" );
338 folder->useFileMetaData();
339 folder->setFolderDescription( cont->folderDescription() );
340 ++nused;
341 break;
342 }
343 }
344 }
345 ATH_MSG_INFO( "Found " << ncontainers << " metadata containers in input file, " << nused << " will be used");
346 } else {
347 ATH_MSG_DEBUG( "Could not retrieve IOVMetaDataContainer objects from MetaDataStore" );
348 }
349
350 // Remove folders which should only be read from file meta data, but
351 // were not found in the MetaDataStore
352
353 // Note: we cannot iterate and perform erase within the iteration
354 // because the iterator becomes invalid. So first collect the keys
355 // to erase in a first pass and then erase them.
356 std::vector<std::string> keysToDelete;
357 for (const auto & thisNamePtrPair : m_foldermap) {
358 if (thisNamePtrPair.second->fromMetaDataOnly() && !thisNamePtrPair.second->readMeta()) {
359 ATH_MSG_INFO( "preLoadAddresses: Removing folder " << thisNamePtrPair.second->folderName() <<
360 ". It should only be in the file meta data and was not found." );
361 keysToDelete.push_back(thisNamePtrPair.first);
362 }
363 }
364
365 for (auto & thisKey : keysToDelete) {
366 FolderMap::iterator fitr=m_foldermap.find(thisKey);
367 if (fitr != m_foldermap.end()) {
368 fitr->second->conn()->decUsage();
369 delete (fitr->second);
370 m_foldermap.erase(fitr);
371 } else {
372 ATH_MSG_ERROR( "preLoadAddresses: Could not find folder " << thisKey << " for removal" );
373 }
374 }
375
376
377 // loop over all folders, grouped by connection
378 // do metadata folders on first connection (default connection)
379 bool doMeta=true;
380 // do not close COOL connection until next one has been opened, this enables
381 // connection sharing in CORAL, so all COOL connections will use the same
382 // CORAL one (althugh they will each be given a separate session)
383 IOVDbConn* oldconn=nullptr;
384 for (const auto & pThisConnection : m_connections) {
385 if (pThisConnection->nFolders()>0 || doMeta) {
386 // loop over all folders using this connection
387 for (const auto & thisNamePtrPair : m_foldermap) {
388 IOVDbFolder* folder=thisNamePtrPair.second;
389 if (folder->conn()==pThisConnection || (folder->conn()==nullptr && doMeta)) {
390 std::unique_ptr<SG::TransientAddress> tad =
391 folder->preLoadFolder( &(*m_h_tagInfoMgr), m_par_cacheRun.value(),
392 m_par_cacheTime.value());
393 if (oldconn!=pThisConnection) {
394 // close old connection if appropriate
395 if (m_par_manageConnections && oldconn!=nullptr) oldconn->setInactive();
396 oldconn=pThisConnection;
397 }
398 if (tad==nullptr) {
399 ATH_MSG_ERROR( "preLoadFolder failed for folder " << folder->folderName() );
400 return StatusCode::FAILURE;
401 }
402 // for write-metadata folder, request data preload
403 if (folder->writeMeta()) {
404 if (StatusCode::SUCCESS!=m_h_IOVSvc->preLoadDataTAD(tad.get(),folder->eventStore())) {
405 ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
406 return StatusCode::FAILURE;
407 }
408 } else {
409 // for other folders, just preload TAD (not data)
410 if (StatusCode::SUCCESS!=m_h_IOVSvc->preLoadTAD(tad.get(), folder->eventStore())) {
411 ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
412 return StatusCode::FAILURE;
413 }
414 }
415 // Add TAD to Storegate
416 tlist.push_back(tad.release());
417 // check for IOV override
418 folder->setIOVOverride(m_par_forceRunNumber.value(),
420 }
421 }
422 }
423 doMeta=false;
424 }
425 // close last connection
426 if (oldconn!=nullptr and m_par_manageConnections) oldconn->setInactive();
427
428 // some folder keys may have changed during preloadFolder due to use of
429 // <key> specification in folder description string
430 // build a new foldermap with the updated keys
431 FolderMap newmap;
432 for (const auto & thisNamePtrPair : m_foldermap) {
433 newmap[thisNamePtrPair.second->key()]=thisNamePtrPair.second;
434 }
435 m_foldermap=std::move(newmap);
436 // fill global and explicit folder tags into TagInfo
437 if (StatusCode::SUCCESS!=fillTagInfo())
438 ATH_MSG_ERROR("Could not fill TagInfo object from preLoadAddresses" );
439 return StatusCode::SUCCESS;
440}
441
442StatusCode IOVDbSvc::loadAddresses(StoreID::type /*storeID*/, tadList& /*list*/ ) {
443 // this method does nothing
444 return StatusCode::SUCCESS;
445}
446
447/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
449 const EventContext& /*ctx*/)
450{
451 // Provide TAD and associated range, actually reading the conditions data
452
453 // Read information for folders and setup TADs
454 if (storeID!=StoreID::DETECTOR_STORE) return StatusCode::FAILURE;
455 Gaudi::Guards::AuditorGuard auditor(std::string("UpdateAddr::")+(tad->name().empty() ? "anonymous" : tad->name()),
456 auditorSvc(), "preLoadProxy");
457
458 IOVTime iovTime{m_iovTime};
459 IOVRange range;
460 std::unique_ptr<IOpaqueAddress> address;
461
462 // first check if this key is managed by IOVDbSvc
463 // return FAILURE if not - this allows other AddressProviders to be
464 // asked for the TAD
465 const std::string& key=tad->name();
466 FolderMap::const_iterator fitr=m_foldermap.find(key);
467 if (fitr==m_foldermap.end()) {
469 "updateAddress cannot find description for TAD " << key );
470 return StatusCode::FAILURE;
471 }
472 IOVDbFolder* folder=fitr->second;
473 if (folder->clid()!=tad->clID()) {
474 ATH_MSG_VERBOSE( "CLID for TAD " << key << " is " << tad->clID()
475 << " but expecting " << folder->clid() );
476
477 return StatusCode::FAILURE;
478 }
479
480 // IOVDbSvc will satisfy the request, using already found folder
481 // now determine the current IOVTime
482 if (m_state==IOVDbSvc::INITIALIZATION && !m_iovTime.isValid()) {
483 ATH_MSG_DEBUG( "updateAddress: in initialisation phase and no iovTime defined" );
484 return::StatusCode::SUCCESS;
485 }
487 // determine iovTime from eventID in the event context
488 const EventIDBase* evid = EventIDFromStore( m_h_sgSvc );
489 if( evid ) {
490 iovTime.setRunEvent( evid->run_number(), evid->lumi_block()) ;
491 // save both seconds and ns offset for timestamp
492 uint64_t nsTime = evid->time_stamp() *1000000000LL;
493 nsTime += evid->time_stamp_ns_offset();
494 iovTime.setTimestamp(nsTime);
495 m_iovTime = iovTime;
496 ATH_MSG_DEBUG( "updateAddress - using iovTime from EventInfo: " << iovTime);
497 } else {
498 // failed to get event info - just return success
499 ATH_MSG_DEBUG( "Could not get event - initialise phase");
500 return StatusCode::SUCCESS;
501 }
502 } else {
503 ATH_MSG_DEBUG("updateAddress: using iovTime from init/beginRun: " << iovTime);
504 }
505
506
507
508 // obtain the validity key for this folder (includes overrides)
509 cool::ValidityKey vkey=folder->iovTime(iovTime);
510 {
511 // The dblock is currently abused to also protect the cache in the IOVDbFolders.
512 // This global lock may give rise to deadlocks between the dblock and the internal lock
513 // of the SGImplSvc. The deadlock may arise if the order of the initial call to IOVDbSvc
514 // and SGImplSvc are different, because the two services call each other.
515 // A problem was observed when SG::DataProxy::isValidAddress first called IOVDbSvc::updateAddress
516 // which called IOVSvc::setRange then SGImplSvc::proxy, and at the same time
517 // StoreGateSvc::contains called first SGImplSvc::proxy which then called IOVDbSvc::updateAddress.
518 // This problem is mitigated by limiting the scope of the dblock here.
519 Athena::DBLock dblock;
520 ATH_MSG_DEBUG("Validity key "<<vkey);
521 if (!folder->readMeta() && !folder->cacheValid(vkey)) {
522 // mark this folder as not-dropped so cache-read will succeed
523 folder->setDropped(false);
524 // reload cache for this folder (and all others sharing this DB connection)
525 ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName());
526 if (StatusCode::SUCCESS!=loadCaches(folder->conn())) {
527 ATH_MSG_ERROR( "Cache load failed for at least one folder from " << folder->conn()->name()
528 << ". You may see errors from other folders sharing the same connection." );
529 return StatusCode::FAILURE;
530 }
531 }
532
533 // data should now be in cache
534 // setup address and range
535 {
536 Gaudi::Guards::AuditorGuard auditor(std::string("FldrSetup:")+(tad->name().empty() ? "anonymous" : tad->name()),
537 auditorSvc(), "preLoadProxy");
538 if (!folder->getAddress(vkey,&(*m_h_persSvc),poolSvcContext(),address,
539 range,m_poolPayloadRequested)) {
540 ATH_MSG_ERROR( "getAddress failed for folder " << folder->folderName() );
541 return StatusCode::FAILURE;
542 }
543 }
544 // reduce minimum IOV of timestamp folders to avoid 'thrashing'
545 // due to events slightly out of order in HLT
546 if (folder->timeStamp()) {
547 cool::ValidityKey start=range.start().timestamp();
548 if (start>m_iovslop) start-=m_iovslop;
549 range=IOVRange(IOVTime(start),range.stop());
550 }
551 }
552
553 // Pass range onto IOVSvc
554 if (StatusCode::SUCCESS!=m_h_IOVSvc->setRange(tad->clID(),tad->name(),
555 range,folder->eventStore())) {
556 ATH_MSG_ERROR( "setRange failed for folder " << folder->folderName() );
557 return StatusCode::FAILURE;
558 }
559 tad->setAddress(address.release());
560 return StatusCode::SUCCESS;
561}
562
563/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
564
565StatusCode IOVDbSvc::getRange( const CLID& clid,
566 const std::string& dbKey,
567 const IOVTime& time,
568 IOVRange& range,
569 std::string& tag,
570 std::unique_ptr<IOpaqueAddress>& address) {
571
572 Athena::DBLock dblock;
573
574 ATH_MSG_DEBUG( "getRange clid: " << clid << " key: \""<< dbKey << "\" t: " << time );
575 const std::string& key=dbKey;
576 FolderMap::const_iterator fitr=m_foldermap.find(key);
577 if (fitr==m_foldermap.end()) {
578 ATH_MSG_VERBOSE("getRange cannot find description for dbKey " << key );
579 return StatusCode::FAILURE;
580 }
581 IOVDbFolder* folder=fitr->second;
582 if (folder->clid()!=clid) {
583 ATH_MSG_VERBOSE( "supplied CLID for " << key << " is "
584 << clid
585 << " but expecting " << folder->clid() );
586
587 return StatusCode::FAILURE;
588 }
589
590 tag = folder->key();
591
592 // obtain the validity key for this folder (includes overrides)
593 cool::ValidityKey vkey=folder->iovTime(time);
594 if (!folder->readMeta() && !folder->cacheValid(vkey)) {
595 // mark this folder as not-dropped so cache-read will succeed
596 folder->setDropped(false);
597 // reload cache for this folder (and all others sharing this DB connection)
598 ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName() );
599 if (StatusCode::SUCCESS!=loadCaches(folder->conn(),&time)) {
600 ATH_MSG_ERROR( "Cache load failed for at least one folder from " << folder->conn()->name()
601 << ". You may see errors from other folders sharing the same connection." );
602 return StatusCode::FAILURE;
603 }
604 }
605
606 // data should now be in cache
607 address.reset();
608 // setup address and range
609 {
610 Gaudi::Guards::AuditorGuard auditor(std::string("FldrSetup:")+(key.empty() ? "anonymous" : key),
611 auditorSvc(), "preLoadProxy");
612 if (!folder->getAddress(vkey,&(*m_h_persSvc),poolSvcContext(),address,
613 range,m_poolPayloadRequested)) {
614 ATH_MSG_ERROR("getAddress failed for folder " <<folder->folderName() );
615 return StatusCode::FAILURE;
616 }
617 }
618
619 // Special handling for extensible folders:
620 if (folder->extensible()) {
621 // Set the end time to just past the current event or lumiblock.
622 IOVTime extStop = range.stop();
623 if (folder->timeStamp()) {
624 extStop.setTimestamp (time.timestamp() + 1);
625 }
626 else {
627 extStop.setRETime (time.re_time() + 1);
628 }
629 range = IOVRange (range.start(), extStop);
630 }
631
632 // Special handling for IOV override: set the infinite validity range
633 if (folder->iovOverridden()) {
634 if (folder->timeStamp()) {
637 }
638 else {
641 }
642 }
643
644 return StatusCode::SUCCESS;
645}
646
647/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
648
649StatusCode IOVDbSvc::setRange( const CLID& /*clid*/,
650 const std::string& /*dbKey*/,
651 const IOVRange& /*range*/,
652 const std::string& /*storeName*/ ) {
653 // this method does nothing
654 return StatusCode::SUCCESS;
655}
656
657StatusCode IOVDbSvc::signalBeginRun(const IOVTime& beginRunTime,
658 const EventContext& ctx)
659{
660 Athena::DBLock dblock;
661
662 // Begin run - set state and save time for later use
664 // Is this a different run compared to the previous call?
665 bool newRun = m_iovTime.isValid() && (m_iovTime.run() != beginRunTime.run());
666 m_iovTime=beginRunTime;
667 // For a MC event, the run number we need to use to look up the conditions
668 // may be different from that of the event itself. Override the run
669 // number with the conditions run number from the event context,
670 // if it is defined.
671 EventIDBase::number_type conditionsRun =
673 if (conditionsRun != EventIDBase::UNDEFNUM) {
674 m_iovTime.setRunEvent (conditionsRun, m_iovTime.event());
675 }
676
677 ATH_MSG_DEBUG( "signalBeginRun> begin run time " << m_iovTime);
678 if (!m_par_onlineMode) {
679 return StatusCode::SUCCESS;
680 }
681
682 // ONLINE mode: allow adding of new calibration constants between runs
683 if (!newRun) {
684 ATH_MSG_DEBUG( "Same run as previous signalBeginRun call. Skipping re-loading of folders..." );
685 return StatusCode::SUCCESS;
686 }
687
688 // all other stuff is event based so happens after this.
689 // this is before first event of each run
690 ATH_MSG_DEBUG( "In online mode will recheck ... " );
691 ATH_MSG_DEBUG( "First reload PoolCataloge ... " );
692
693 pool::IFileCatalog* catalog ATLAS_THREAD_SAFE = // we are not within the event loop yet
694 const_cast<pool::IFileCatalog*>(m_h_poolSvc->catalog());
695 catalog->commit();
696 catalog->start();
697
698 for (const auto & pThisConnection : m_connections){
699 // only access connections which are actually in use - avoids waking up
700 // the default DB connection if it is not being used
701 if (pThisConnection->nFolders()>0) {
702 //request for database activates connection
703 cool::IDatabasePtr dbconn=pThisConnection->getCoolDb();
704 if (dbconn.get()==nullptr) {
705 ATH_MSG_FATAL( "Conditions database connection " << pThisConnection->name() << " cannot be opened - STOP" );
706 return StatusCode::FAILURE;
707 }
708 for (const auto & thisNamePtrPair: m_foldermap) {
709 IOVDbFolder* folder=thisNamePtrPair.second;
710 if (folder->conn()!=pThisConnection) continue;
711 folder->printCache();
712 cool::ValidityKey vkey=folder->iovTime(m_iovTime);
713 {
714 Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
715 if (!folder->loadCacheIfDbChanged(vkey, m_globalTag, dbconn, m_h_IOVSvc)) {
716 ATH_MSG_ERROR( "Problem RELOADING: " << folder->folderName());
717 return StatusCode::FAILURE;
718 }
719 }
720 folder->printCache();
721 }
722 }
723 if (m_par_manageConnections) pThisConnection->setInactive();
724 }
725 return StatusCode::SUCCESS;
726}
727
729 // this method does nothing
730}
731
733 // Close any open POOL files after loding Conditions
734 ATH_MSG_DEBUG( "postConditionsLoad: m_par_managePoolConnections=" << m_par_managePoolConnections
735 << " m_poolPayloadRequested=" << m_poolPayloadRequested );
736
738 // reset POOL connection to close all open conditions POOL files
741 if( m_poolSvcContext ) {
742 if (StatusCode::SUCCESS==m_h_poolSvc->disconnect(m_poolSvcContext)) {
743 ATH_MSG_DEBUG( "Successfully closed input POOL connections");
744 } else {
745 ATH_MSG_WARNING( "Unable to close input POOL connections" );
746 }
747 // reopen transaction
748 if (StatusCode::SUCCESS==m_h_poolSvc->connect(pool::ITransaction::READ, m_poolSvcContext)) {
749 ATH_MSG_DEBUG("Reopend read transaction for POOL conditions input files" );
750 } else {
751 ATH_MSG_WARNING("Cannot reopen read transaction for POOL conditions input files");
752 }
753 }
754 }
755}
756
757void IOVDbSvc::handle( const Incident& inc) {
758 // Handle incidents:
759 // BeginEvent to set IOVDbSvc state to EVENT_LOOP
760 // StoreCleared/EndProcessing to close any open POOL files
761 ATH_MSG_VERBOSE( "entering handle(), incident type " << inc.type() << " from " << inc.source() );
762 if (inc.type()=="BeginEvent") {
764 } else {
765 Athena::DBLock dblock;
766
767 const StoreClearedIncident* sinc = dynamic_cast<const StoreClearedIncident*>(&inc);
768 if( (inc.type()=="StoreCleared" && sinc!=nullptr && sinc->store()==&*m_h_sgSvc
770 or inc.type()==IncidentType::EndProcessing )
771 {
774 }
775 }
776}
777
779 // Processing of taginfo
780 // Set GlobalTag and any folder-specific overrides if given
781
782 // dump out contents of TagInfo
783 ATH_MSG_DEBUG( "Tags from input TagInfo:");
784 if( msg().level()>=MSG::DEBUG ) m_h_tagInfoMgr->printTags(msg());
785
786 // check IOVDbSvc GlobalTag, if not already set
787 if (m_globalTag.empty()) {
788 m_globalTag = m_h_tagInfoMgr->findTag("IOVDbGlobalTag");
789 if (!m_globalTag.empty()) ATH_MSG_INFO( "Global tag: " << m_globalTag<< " set from input file" );
791 }
792
793 // now check for tag overrides for specific folders
794 const ITagInfoMgr::NameTagPairVec nameTagPairs = m_h_tagInfoMgr->getInputTags();
795 for (const auto & thisNameTagPair: nameTagPairs) {
796 // assume tags relating to conditions folders start with /
797 if (not refersToConditionsFolder(thisNameTagPair)) continue;
798 // check for folder(s) with this name in (key, ptr) pair
799 for (const auto & thisKeyPtrPair: m_foldermap) {
800 IOVDbFolder* folder=thisKeyPtrPair.second;
801 const std::string& ifname=folder->folderName();
802 if (ifname!=thisNameTagPair.first) continue;
803 // use an override from TagInfo only if there is not an explicit jo tag,
804 // and folder meta-data is not used, and there is no <noover/> spec,
805 // and no global tag set in job options
806 const auto & theTag{thisNameTagPair.second};
807 if (folder->joTag().empty() && !folder->readMeta() && !folder->noOverride() && m_par_globalTag.empty()) {
808 folder->setTagOverride(theTag,false);
809 ATH_MSG_INFO( "TagInfo override for tag " << theTag << " in folder " << ifname );
810 } else if (folder->joTag()!=theTag) {
811 const std::string_view tagTypeString=(folder->joTag().empty()) ? "hierarchical" : "jobOption";
812 ATH_MSG_INFO( "Ignoring inputfile TagInfo request for tag " << theTag << " in folder " << ifname<<" in favour of "<<tagTypeString);
813 }
814 }
815 }
816 return StatusCode::SUCCESS;
817}
818
819std::vector<std::string>
821 // return a list of all the StoreGate keys being managed by IOVDbSvc
822 std::vector<std::string> keys;
823 keys.reserve(m_foldermap.size());
824 std::for_each(m_foldermap.begin(),m_foldermap.end(), [&keys](const auto &i){keys.emplace_back(i.first);});
825 return keys;
826}
827
828bool IOVDbSvc::getKeyInfo(const std::string& key, IIOVDbSvc::KeyInfo& info) {
829 // return information about given SG key
830 // first attempt to find the folder object for this key
831 FolderMap::const_iterator itr = m_foldermap.find(key);
832 if (itr!=m_foldermap.end()) {
833 const IOVDbFolder* f=itr->second;
834 info.folderName = f->folderName();
835 info.tag = f->resolvedTag();
836 info.range = f->currentRange();
837 info.retrieved = f->retrieved();
838 info.bytesRead = f->bytesRead();
839 info.readTime = f->readTime();
840 info.extensible = f->extensible();
841 return true;
842 } else {
843 info.retrieved = false;
844 return false;
845 }
846}
847
848bool IOVDbSvc::dropObject(const std::string& key, const bool resetCache) {
849 // find the folder corresponding to this object
850 FolderMap::const_iterator itr=m_foldermap.find(key);
851 if (itr!=m_foldermap.end()) {
852 IOVDbFolder* folder=itr->second;
853 CLID clid=folder->clid();
854 SG::DataProxy* proxy=m_h_detStore->proxy(clid,key);
855 if (proxy!=nullptr) {
856 m_h_detStore->clearProxyPayload(proxy);
857 ATH_MSG_DEBUG("Dropped payload for key " << key );
858 folder->setDropped(true);
859 if (resetCache) {
860 folder->resetCache();
861 ATH_MSG_DEBUG( "Cache reset done for folder " << folder->folderName() );
862 }
863 return true;
864 } else {
865 return false;
866 }
867 } else {
868 return false;
869 }
870}
871
872
873/************************/
874// private methods of IOVDbSvc
875
877 // check if EventSelector is being used to override run numbers
878 // if so, we can set IOV time already to allow conditons retrieval
879 // in the initialise phase, needed for setting up simulation
880
881 ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc",name());
882 ATH_CHECK( joSvc.retrieve() );
883
884 if (!joSvc->has("EventSelector.OverrideRunNumber")) {
885 // do not return FAILURE if the EventSelector cannot be found, or it has
886 // no override property, can e.g. happen in online running
887 ATH_MSG_DEBUG( "No EventSelector.OverrideRunNumber property found" );
888 return StatusCode::SUCCESS;
889 }
890
891 BooleanProperty bprop("OverrideRunNumber",false);
892 ATH_CHECK( bprop.fromString(joSvc->get("EventSelector.OverrideRunNumber")) );
893 if (bprop.value()) {
894 // if flag is set, extract Run,LB and time
895 ATH_MSG_INFO( "Setting run/LB/time from EventSelector override in initialize" );
896 uint32_t run,lumib;
897 uint64_t time;
898 bool allGood=true;
899 if (m_par_forceRunNumber.value()!=0 ||
901 ATH_MSG_WARNING( "forceRunNumber property also set" );
902 IntegerProperty iprop1("RunNumber",0);
903 if (iprop1.fromString(joSvc->get("EventSelector.RunNumber","INVALID"))) {
904 run=iprop1.value();
905 } else {
906 ATH_MSG_ERROR( "Unable to get RunNumber from EventSelector");
907 allGood=false;
908 }
909 IntegerProperty iprop2("FirstLB",0);
910 if (iprop2.fromString(joSvc->get("EventSelector.FirstLB","INVALID"))) {
911 lumib=iprop2.value();
912 } else {
913 ATH_MSG_ERROR( "Unable to get FirstLB from EventSelector");
914 allGood=false;
915 }
916 IntegerProperty iprop3("InitialTimeStamp",0);
917 if (iprop3.fromString(joSvc->get("EventSelector.InitialTimeStamp","INVALID"))) {
918 time=iprop3.value();
919 } else {
920 ATH_MSG_ERROR("Unable to get InitialTimeStamp from EventSelector" );
921 allGood=false;
922 }
923 if (allGood) {
924 m_iovTime.setRunEvent(run,lumib);
925 uint64_t nsTime=time*1000000000LL;
926 m_iovTime.setTimestamp(nsTime);
927 ATH_MSG_INFO( "run/LB/time set to [" << run << "," << lumib << " : " << nsTime << "]" );
928 } else {
929 ATH_MSG_ERROR( "run/LB/Time NOT changed" );
930 }
931 }
932
933 return StatusCode::SUCCESS;
934}
935
937 // read the Folders joboptions and setup the folder list
938 // no wildcards are allowed
939
940 // getting the pairs: folder name - CREST tag name:
941 if (m_par_source == "CREST"){
942 m_cresttagmap.clear();
944 }
945
946 //1. Loop through folders
947 std::list<IOVDbParser> allFolderdata;
948 for (const auto & thisFolder : m_par_folders.value()) {
949 ATH_MSG_DEBUG( "Setup folder " << thisFolder );
950 IOVDbParser folderdata(thisFolder,msg());
951 if (!folderdata.isValid()) {
952 ATH_MSG_FATAL("setupFolders: Folder setup string is invalid: " <<thisFolder);
953 return StatusCode::FAILURE;
954 }
955
956 allFolderdata.push_back(std::move(folderdata));
957 }
958
959 //2. Loop through overwrites:
960 // syntax for entries is <prefix>folderpath</prefix> <tag>value</tag>
961 // folderpath matches from left of folderName
962 // but if partial match, next character must be / so override for /Fred/Ji
963 // matches /Fred/Ji/A and /Fred/Ji but not /Fred/Jim
964
965 for (const auto & thisOverrideTag : m_par_overrideTags) {
966 IOVDbParser keys(thisOverrideTag,msg());
967 if (not keys.isValid()){
968 ATH_MSG_ERROR("An override tag was invalid: " << thisOverrideTag);
969 return StatusCode::FAILURE;
970 }
971 std::string prefix;
972 if (!keys.getKey("prefix","",prefix)) { // || !keys.getKey("tag","",tag)) {
973 ATH_MSG_ERROR( "Problem in overrideTag specification " <<thisOverrideTag );
974 return StatusCode::FAILURE;
975 }
976
977 for (auto& folderdata : allFolderdata) {
978 const std::string& ifname=folderdata.folderName();
979 if (ifname.compare(0,prefix.size(), prefix)==0 &&
980 (ifname.size()==prefix.size() || ifname[prefix.size()]=='/')) {
981 //Match!
982 folderdata.applyOverrides(keys,msg());
983 }// end if
984 }// end loop over allFolderdata
985 }// end loop over overrides
986
987 //3. Remove any duplicates:
988 std::list<IOVDbParser>::iterator it1=allFolderdata.begin();
989 std::list<IOVDbParser>::iterator it_e=allFolderdata.end();
990 for (;it1!=it_e;++it1) {
991 const IOVDbParser& folder1=*it1;
992 std::list<IOVDbParser>::iterator it2=it1;
993 ++it2;
994 while(it2!=it_e) {
995 const IOVDbParser& folder2=*it2;
996 if (folder1==folder2) {
997 it2=allFolderdata.erase(it2); //FIXME: Smarter distinction/reporting about same folder but different keys.
998 ATH_MSG_DEBUG( "Removing duplicate folder " << folder1.folderName());
999 } else {
1000 ++it2;
1001 //Catch suspicous cases:
1002 if (folder1.folderName()==folder2.folderName()) {
1003 ATH_MSG_WARNING( "Folder name appears twice: " << folder1.folderName() );
1004 ATH_MSG_WARNING( folder1 << " vs " << folder2 );
1005 }
1006 }
1007 }//end inner loop
1008 }//end outer loop
1009
1010 //4.Set up folder map with cleaned folder list
1011
1012 bool hasError=false;
1013 for (const auto& folderdata : allFolderdata) {
1014 // find the connection specification first - db or dbConnection
1015 // default is to use the 'default' connection
1016 IOVDbConn* conn=nullptr;
1017 std::string connstr;
1018 if (folderdata.getKey("db","",connstr) ||
1019 folderdata.getKey("dbConnection","",connstr)) {
1020 // an explicit database name is specified
1021 // check if it is already present in the existing connections
1022 for (const auto & pThisConnection : m_connections) {
1023 if (pThisConnection->name()==connstr) {
1024 // found existing connection - use that
1025 conn=pThisConnection;
1026 break;
1027 }
1028 }
1029 if (conn==nullptr) {
1030 // create new read-onlyconnection
1031 conn=new IOVDbConn(connstr,true,msg());
1032 m_connections.push_back(conn);
1033 }
1034 } else {
1035 // no connection specified - use default if available
1036 if (!m_par_defaultConnection.empty()) {
1037 conn=m_connections[0];
1038 } else {
1039 ATH_MSG_FATAL( "Folder request " << folderdata.folderName() <<
1040 " gives no DB connection information and no default set" );
1041 return StatusCode::FAILURE;
1042 }
1043 }
1044
1045 // create the new folder, but only if a folder for this SG key has not
1046 // already been requested
1047
1048 std::string crestTag = "";
1049 if (m_par_source == "CREST"){
1050 crestTag = m_cresttagmap[folderdata.folderName()];
1051 if(crestTag.size()==0 && folderdata.folderName().compare("/TagInfo")!=0){
1052 ATH_MSG_FATAL( "Global Tag "<<m_par_globalTag<<" hasn't folder: " << folderdata.folderName() <<
1053 " in Global Tag Map." );
1054 hasError=true;
1055 continue;
1056 }
1057 }
1058
1059 IOVDbFolder* folder=new IOVDbFolder(conn,folderdata,msg(),&(*m_h_clidSvc), &(*m_h_metaDataTool),
1061 const std::string& key=folder->key();
1062 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).
1063 m_foldermap[key]=folder;
1064 conn->incUsage();
1065 } else {
1066 ATH_MSG_ERROR( "Duplicate request for folder " <<
1067 folder->folderName() <<
1068 " associated to already requested Storegate key " << key );
1069 // clean up this duplicate request
1070 delete folder;
1071 }
1072 }// end loop over folders
1073 // check for folders to be written to metadata
1074 if(hasError)
1075 return StatusCode::FAILURE;
1076 for (const auto & folderToWrite : m_par_foldersToWrite) {
1077 // match wildcard * at end of string only (i.e. /A/* matches /A/B, /A/C/D)
1078 std::string_view match=folderToWrite;
1079 std::string::size_type idx=folderToWrite.find('*');
1080 if (idx!=std::string::npos) {
1081 match=std::string_view(folderToWrite).substr(0,idx);
1082 }
1083 for (const auto & thisFolder : m_foldermap) {
1084 IOVDbFolder* fptr=thisFolder.second;
1085 if ((fptr->folderName()).compare(0,match.size(), match)==0) {
1086 fptr->setWriteMeta();
1087 ATH_MSG_INFO( "Folder " << fptr->folderName() << " will be written to file metadata" );
1088 }
1089 }//end loop over FolderMap
1090 }//end loop over m_par_foldersToWrite
1091 return StatusCode::SUCCESS;
1092}
1093
1095 if (!m_par_globalTag.empty()) {
1096 ATH_MSG_DEBUG( "Adding GlobalTag " << m_par_globalTag << " into TagInfo" );
1097 if (StatusCode::SUCCESS!=m_h_tagInfoMgr->addTag("IOVDbGlobalTag",m_par_globalTag))
1098 return StatusCode::FAILURE;
1099 }
1100 // add all explicit tags specified in folders
1101 // can be from Folders or tagOverrides properties
1102 for (const auto & thisFolder : m_foldermap) {
1103 const IOVDbFolder* folder=thisFolder.second;
1104 if (!folder->joTag().empty()) {
1105 ATH_MSG_DEBUG( "Adding folder " << folder->folderName() <<" tag " << folder->joTag() << " into TagInfo" );
1106 if (StatusCode::SUCCESS!=m_h_tagInfoMgr->addTag(folder->folderName(),folder->joTag()))
1107 return StatusCode::FAILURE;
1108 }
1109 // check to see if any input TagInfo folder overrides should be removed
1110 // this anticipates the decisions which will be made in processTagInfo
1111 // Here we do not have access to the TagInfo object, but can put remove
1112 // requests in for all folders if the global tag is set, or if there is
1113 // an explict joboption tag, nooverride spec, or data comes from metadata
1114 if (!m_par_globalTag.empty() || !folder->joTag().empty() || folder->noOverride() ||
1115 folder->readMeta()) {
1116 if (StatusCode::SUCCESS!=
1117 m_h_tagInfoMgr->removeTagFromInput(folder->folderName())) {
1118 ATH_MSG_WARNING( "Could not add TagInfo remove request for "
1119 << folder->folderName() );
1120 } else {
1121 ATH_MSG_INFO( "Added taginfo remove for " <<
1122 folder->folderName() );
1123 }
1124 }
1125 }
1126 return StatusCode::SUCCESS;
1127}
1128
1129StatusCode IOVDbSvc::loadCaches(IOVDbConn* conn, const IOVTime* time) {
1130 // load the caches for all folders using the given connection
1131 // so connection use is optimised
1132
1133 Gaudi::Guards::AuditorGuard auditor(std::string("loadCachesOverhead:")+conn->name(), auditorSvc(), "preLoadProxy");
1134
1135 ATH_MSG_DEBUG( "loadCaches: Begin for connection " << conn->name());
1136 // if global abort already set, load nothing
1137 if (m_abort) return StatusCode::FAILURE;
1138 bool access=false;
1139 StatusCode sc=StatusCode::SUCCESS;
1140 for (const auto & thisNamePtrPair : m_foldermap) {
1141 IOVDbFolder* folder=thisNamePtrPair.second;
1142 if (folder->conn()!=conn) continue;
1143 cool::ValidityKey vkey=folder->iovTime(time==nullptr ? m_iovTime : *time);
1144 // protect against out of range times (timestamp -1 happened in FDR2)
1145 if (vkey>cool::ValidityKeyMax) {
1146 ATH_MSG_WARNING( "Requested validity key " << vkey << " is out of range, reset to 0" );
1147 vkey=0;
1148 }
1149 if (!folder->cacheValid(vkey) && !folder->dropped()) {
1150 access=true;
1151 {
1152 Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
1153 if (!folder->loadCache(vkey,m_par_cacheAlign,m_globalTag,m_par_onlineMode)) {
1154 ATH_MSG_ERROR( "Cache load (prefetch) failed for folder " << folder->folderName() );
1155 // remember the failure, but also load other folders on this connection
1156 // while it is open
1157 sc=StatusCode::FAILURE;
1158 }
1159 }
1160 }
1161 }
1162 // disconnect from database if we connected
1163 if (access && m_par_manageConnections) conn->setInactive();
1164 // if connection aborted, set overall abort so we do not waste time trying
1165 // to read data from other schema
1166 if (conn->aborted()) {
1167 ATH_MSG_FATAL( "Connection " << conn->name() << " was aborted, set global abort" );
1168 m_abort=true;
1169 ATH_MSG_FATAL( "loadCache: impossible to load cache!" );
1170 throw std::exception();
1171 }
1172 return sc;
1173}
1174
1176// check consistency of global tag and database instance, if set
1177 // catch most common user misconfigurations
1178 // this is only done here as need global tag to be set even if read from file
1179 // @TODO should this not be done during initialize
1180 if (!m_par_dbinst.empty() && !m_globalTag.empty() and (m_par_source!="CREST")) {
1181 const std::string_view tagstub=std::string_view(m_globalTag).substr(0,7);
1182 ATH_MSG_DEBUG( "Checking " << m_par_dbinst << " against " <<tagstub );
1183 if (((m_par_dbinst=="COMP200" || m_par_dbinst=="CONDBR2") &&
1184 (tagstub!="COMCOND" && tagstub!="CONDBR2")) ||
1185 (m_par_dbinst=="OFLP200" && (tagstub!="OFLCOND" && tagstub!="CMCCOND"))) {
1186 ATH_MSG_FATAL( "Likely incorrect conditions DB configuration! "
1187 << "Attached to database instance " << m_par_dbinst <<
1188 " but global tag begins " << tagstub );
1189 ATH_MSG_FATAL( "See Atlas/CoolTroubles wiki for details," <<
1190 " or set IOVDbSvc.DBInstance=\"\" to disable check" );
1191 return StatusCode::FAILURE;
1192 }
1193 }
1194 return StatusCode::SUCCESS;
1195}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Header for CoralCrestManager class.
Common database lock.
const EventIDBase * EventIDFromStore(IProxyDict *store)
Retrieve the EventID from EventContext saved in store STORE.
uint32_t CLID
The Class ID type.
Athena service for Interval Of Validity database.
This class is a container for conditions data.
Validity Range object.
static Double_t sc
Incident sent after a store is cleared.
static const Attributes_t empty
Define macros for attributes used to control the static checker.
#define ATLAS_THREAD_SAFE
Common database lock.
Definition DBLock.h:46
EventIDBase::number_type conditionsRun() const
static std::map< std::string, std::string > getGlobalTagMap(const std::string &crest_path, const std::string &globaltag)
void setInactive()
bool isValid() const
Definition IOVDbParser.h:67
virtual StatusCode finalize() override
Service finalize.
Definition IOVDbSvc.cxx:258
BooleanProperty m_par_managePoolConnections
Definition IOVDbSvc.h:199
StatusCode loadCaches(IOVDbConn *conn, const IOVTime *time=nullptr)
PublicToolHandle< IIOVDbMetaDataTool > m_h_metaDataTool
Definition IOVDbSvc.h:241
ServiceHandle< StoreGateSvc > m_h_sgSvc
Definition IOVDbSvc.h:235
Gaudi::Property< std::vector< std::string > > m_par_overrideTags
Definition IOVDbSvc.h:193
virtual void handle(const Incident &incident) override
Incident service handle for EndEvent.
Definition IOVDbSvc.cxx:757
Gaudi::Property< std::vector< std::string > > m_par_folders
Definition IOVDbSvc.h:191
virtual cool::IDatabasePtr getDatabase(bool readOnly) override
Access to COOL database for a given folder.
Definition IOVDbSvc.cxx:297
BooleanProperty m_crestCoolToFile
Definition IOVDbSvc.h:231
virtual bool dropObject(const std::string &key, const bool resetCache=false) override
Definition IOVDbSvc.cxx:848
IAddressProvider::tadList tadList
Definition IOVDbSvc.h:102
std::map< std::string, IOVDbFolder * > FolderMap
Definition IOVDbSvc.h:280
BooleanProperty m_outputToFile
Definition IOVDbSvc.h:230
BooleanProperty m_par_checklock
Definition IOVDbSvc.h:220
IntegerProperty m_par_forceLumiblockNumber
Definition IOVDbSvc.h:203
BooleanProperty m_par_manageConnections
Definition IOVDbSvc.h:197
virtual StatusCode preLoadAddresses(StoreID::type storeID, tadList &list) override
Get all addresses that the provider wants to preload in SG maps.
Definition IOVDbSvc.cxx:315
StatusCode io_finalize() override final
Definition IOVDbSvc.cxx:253
ServiceHandle< IAddressCreator > m_h_persSvc
Definition IOVDbSvc.h:238
bool m_abort
Definition IOVDbSvc.h:283
std::map< std::string, std::string > m_cresttagmap
Definition IOVDbSvc.h:226
StatusCode checkConfigConsistency() const
virtual ~IOVDbSvc()
IOVTime m_iovTime
Definition IOVDbSvc.h:268
IntegerProperty m_par_maxNumPoolFiles
Definition IOVDbSvc.h:207
UnsignedIntegerProperty m_par_cacheAlign
Definition IOVDbSvc.h:216
StatusCode io_reinit() override final
Definition IOVDbSvc.cxx:246
IntegerProperty m_par_forceTimestamp
Definition IOVDbSvc.h:205
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.
Definition IOVDbSvc.cxx:649
IntegerProperty m_par_cacheRun
Definition IOVDbSvc.h:211
@ FINALIZE_ALG
Definition IOVDbSvc.h:263
@ BEGIN_RUN
Definition IOVDbSvc.h:261
@ INITIALIZATION
Definition IOVDbSvc.h:260
@ EVENT_LOOP
Definition IOVDbSvc.h:262
virtual StatusCode initialize() override
Service init.
Definition IOVDbSvc.cxx:160
StatusCode checkEventSel()
Definition IOVDbSvc.cxx:876
virtual void postConditionsLoad() override
May be called once conditions are loaded to let IOVDbSvc release resources.
Definition IOVDbSvc.cxx:732
BooleanProperty m_par_onlineMode
Definition IOVDbSvc.h:218
ServiceHandle< StoreGateSvc > m_h_metaDataStore
Definition IOVDbSvc.h:237
ServiceHandle< IClassIDSvc > m_h_clidSvc
Definition IOVDbSvc.h:239
ServiceHandle< ITagInfoMgr > m_h_tagInfoMgr
Definition IOVDbSvc.h:242
Gaudi::Property< std::string > m_par_dbinst
Definition IOVDbSvc.h:189
virtual StatusCode signalBeginRun(const IOVTime &beginRunTime, const EventContext &ctx) override
Set time for begin run.
Definition IOVDbSvc.cxx:657
ConnVec m_connections
Definition IOVDbSvc.h:278
int m_poolSvcContext
Definition IOVDbSvc.h:251
ServiceHandle< IPoolSvc > m_h_poolSvc
Definition IOVDbSvc.h:240
StatusCode fillTagInfo()
int poolSvcContext()
Definition IOVDbSvc.cxx:141
bool m_poolPayloadRequested
Definition IOVDbSvc.h:247
StatusCode setupFolders()
Definition IOVDbSvc.cxx:936
ServiceHandle< StoreGateSvc > m_h_detStore
Definition IOVDbSvc.h:236
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.
Definition IOVDbSvc.cxx:828
Gaudi::Property< std::string > m_par_defaultConnection
Definition IOVDbSvc.h:185
virtual StatusCode loadAddresses(StoreID::type storeID, tadList &list) override
Get all new addresses from Provider for this Event.
Definition IOVDbSvc.cxx:442
virtual StatusCode updateAddress(StoreID::type storeID, SG::TransientAddress *tad, const EventContext &ctx) override
Update a transient Address.
Definition IOVDbSvc.cxx:448
IOVDbSvc_state m_state
Definition IOVDbSvc.h:265
virtual std::vector< std::string > getKeyList() override
Definition IOVDbSvc.cxx:820
virtual void signalEndProxyPreload() override
Signal that callback has been fired.
Definition IOVDbSvc.cxx:728
IntegerProperty m_par_cacheTime
Definition IOVDbSvc.h:213
Gaudi::Property< std::vector< std::string > > m_par_foldersToWrite
Definition IOVDbSvc.h:195
Gaudi::Property< std::string > m_par_globalTag
Definition IOVDbSvc.h:187
IntegerProperty m_par_forceRunNumber
Definition IOVDbSvc.h:201
StringProperty m_par_crestServer
Definition IOVDbSvc.h:224
virtual StatusCode processTagInfo() override
Process TagInfo.
Definition IOVDbSvc.cxx:778
StringProperty m_par_source
Definition IOVDbSvc.h:222
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.
Definition IOVDbSvc.cxx:565
FloatProperty m_par_timeStampSlop
Definition IOVDbSvc.h:209
std::string m_globalTag
Definition IOVDbSvc.h:271
FolderMap m_foldermap
Definition IOVDbSvc.h:281
cool::ValidityKey m_iovslop
Definition IOVDbSvc.h:274
ServiceHandle< IIOVSvc > m_h_IOVSvc
Definition IOVDbSvc.h:234
Validity Range object.
Definition IOVRange.h:30
Basic time unit for IOVSvc.
Definition IOVTime.h:33
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
void setRunEvent(uint32_t run, uint32_t event) noexcept
Definition IOVTime.cxx:96
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
uint32_t run() const noexcept
Definition IOVTime.h:105
static constexpr uint32_t MAXEVENT
Definition IOVTime.h:51
static constexpr uint32_t MINRUN
Definition IOVTime.h:44
std::vector< NameTagPair > NameTagPairVec
Definition ITagInfoMgr.h:66
std::pair< std::string, std::string > NameTagPair
Definition ITagInfoMgr.h:65
a const_iterator facade to DataHandle.
Definition SGIterator.h:164
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.
Incident sent after a store is cleared.
const StoreGateSvc * store() const
Return the store that was cleared.
@ DETECTOR_STORE
Definition StoreID.h:27
void commit()
Save catalog to file.
std::vector< TFile * > fptr
Definition hcg.cxx:51
std::string description
glabal timer - how long have I taken so far?
Definition hcg.cxx:91
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
bool match(std::string s1, std::string s2)
match the individual directories of two strings
Definition hcg.cxx:357
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
openDatabase(dbstring)
Definition run.py:1
STL namespace.
Filled by IIOVDbSvc::getKeyInfo.
Definition IIOVDbSvc.h:44
MsgStream & msg
Definition testRead.cxx:32