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