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 #include "CoralCrestManager.h"
30 
31 #include <algorithm>
32 #include <list>
33 #include <utility>
34 
35 // helper function for getting jobopt properties
36 namespace {
37  bool
38  refersToConditionsFolder(const ITagInfoMgr::NameTagPair & thisPair){
39  return thisPair.first.front() == '/';
40  }
41 
42 
43 // Wrap a cool IDatabase with a DBLock.
44 class LockedDatabase
45  : public cool::IDatabase
46 {
47 public:
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
112  virtual ITransactionPtr startTransaction() override
114  { return m_dbptr->startTransaction(); }
115 #endif
116 
117 
118 private:
119  cool::IDatabasePtr m_dbptr;
120  Athena::DBLock m_dblock;
121 };
122 
123 
124 LockedDatabase::LockedDatabase (cool::IDatabasePtr dbptr,
125  const Athena::DBLock& dblock)
126  : m_dbptr (std::move(dbptr)),
127  m_dblock (dblock)
128 {
129 }
130 
131 
132 LockedDatabase::~LockedDatabase()
133 = default;
134 
135 
136 } // anonymous namespace
137 
138 
139 IOVDbSvc::~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 
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 
297 cool::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  // take data from FLMD only if tag override is NOT set
335  if (thisNamePtrPair.second->folderName()==fname && !(thisNamePtrPair.second->tagOverride())) {
336  ATH_MSG_INFO( "Folder " << fname << " will be taken from file metadata" );
337  thisNamePtrPair.second->useFileMetaData();
338  thisNamePtrPair.second->setFolderDescription( cont->folderDescription() );
339  ++nused;
340  break;
341  }
342  }
343  }
344  ATH_MSG_INFO( "Found " << ncontainers << " metadata containers in input file, " << nused << " will be used");
345  } else {
346  ATH_MSG_DEBUG( "Could not retrieve IOVMetaDataContainer objects from MetaDataStore" );
347  }
348 
349  // Remove folders which should only be read from file meta data, but
350  // were not found in the MetaDataStore
351 
352  // Note: we cannot iterate and perform erase within the iteration
353  // because the iterator becomes invalid. So first collect the keys
354  // to erase in a first pass and then erase them.
355  std::vector<std::string> keysToDelete;
356  for (const auto & thisNamePtrPair : m_foldermap) {
357  if (thisNamePtrPair.second->fromMetaDataOnly() && !thisNamePtrPair.second->readMeta()) {
358  ATH_MSG_INFO( "preLoadAddresses: Removing folder " << thisNamePtrPair.second->folderName() <<
359  ". It should only be in the file meta data and was not found." );
360  keysToDelete.push_back(thisNamePtrPair.first);
361  }
362  }
363 
364  for (auto & thisKey : keysToDelete) {
365  FolderMap::iterator fitr=m_foldermap.find(thisKey);
366  if (fitr != m_foldermap.end()) {
367  fitr->second->conn()->decUsage();
368  delete (fitr->second);
369  m_foldermap.erase(fitr);
370  } else {
371  ATH_MSG_ERROR( "preLoadAddresses: Could not find folder " << thisKey << " for removal" );
372  }
373  }
374 
375 
376  // loop over all folders, grouped by connection
377  // do metadata folders on first connection (default connection)
378  bool doMeta=true;
379  // do not close COOL connection until next one has been opened, this enables
380  // connection sharing in CORAL, so all COOL connections will use the same
381  // CORAL one (althugh they will each be given a separate session)
382  IOVDbConn* oldconn=nullptr;
383  for (const auto & pThisConnection : m_connections) {
384  if (pThisConnection->nFolders()>0 || doMeta) {
385  // loop over all folders using this connection
386  for (const auto & thisNamePtrPair : m_foldermap) {
387  IOVDbFolder* folder=thisNamePtrPair.second;
388  if (folder->conn()==pThisConnection || (folder->conn()==nullptr && doMeta)) {
389  std::unique_ptr<SG::TransientAddress> tad =
390  folder->preLoadFolder( &(*m_h_tagInfoMgr), m_par_cacheRun.value(),
391  m_par_cacheTime.value());
392  if (oldconn!=pThisConnection) {
393  // close old connection if appropriate
394  if (m_par_manageConnections && oldconn!=nullptr) oldconn->setInactive();
395  oldconn=pThisConnection;
396  }
397  if (tad==nullptr) {
398  ATH_MSG_ERROR( "preLoadFolder failed for folder " << folder->folderName() );
399  return StatusCode::FAILURE;
400  }
401  // for write-metadata folder, request data preload
402  if (folder->writeMeta()) {
403  if (StatusCode::SUCCESS!=m_h_IOVSvc->preLoadDataTAD(tad.get(),folder->eventStore())) {
404  ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
405  return StatusCode::FAILURE;
406  }
407  } else {
408  // for other folders, just preload TAD (not data)
409  if (StatusCode::SUCCESS!=m_h_IOVSvc->preLoadTAD(tad.get(), folder->eventStore())) {
410  ATH_MSG_ERROR( "Could not request IOVSvc to preload metadata for " << folder->folderName() );
411  return StatusCode::FAILURE;
412  }
413  }
414  // Add TAD to Storegate
415  tlist.push_back(tad.release());
416  // check for IOV override
417  folder->setIOVOverride(m_par_forceRunNumber.value(),
419  }
420  }
421  }
422  doMeta=false;
423  }
424  // close last connection
425  if (oldconn!=nullptr and m_par_manageConnections) oldconn->setInactive();
426 
427  // some folder keys may have changed during preloadFolder due to use of
428  // <key> specification in folder description string
429  // build a new foldermap with the updated keys
430  FolderMap newmap;
431  for (const auto & thisNamePtrPair : m_foldermap) {
432  newmap[thisNamePtrPair.second->key()]=thisNamePtrPair.second;
433  }
434  m_foldermap=newmap;
435  // fill global and explicit folder tags into TagInfo
436  if (StatusCode::SUCCESS!=fillTagInfo())
437  ATH_MSG_ERROR("Could not fill TagInfo object from preLoadAddresses" );
438  return StatusCode::SUCCESS;
439 }
440 
442  // this method does nothing
443  return StatusCode::SUCCESS;
444 }
445 
446 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
448  const EventContext& /*ctx*/)
449 {
450  // Provide TAD and associated range, actually reading the conditions data
451 
452  // Read information for folders and setup TADs
453  if (storeID!=StoreID::DETECTOR_STORE) return StatusCode::FAILURE;
454  Gaudi::Guards::AuditorGuard auditor(std::string("UpdateAddr::")+(tad->name().empty() ? "anonymous" : tad->name()),
455  auditorSvc(), "preLoadProxy");
456 
457  IOVTime iovTime{m_iovTime};
458  IOVRange range;
459  std::unique_ptr<IOpaqueAddress> address;
460 
461  // first check if this key is managed by IOVDbSvc
462  // return FAILURE if not - this allows other AddressProviders to be
463  // asked for the TAD
464  const std::string& key=tad->name();
465  FolderMap::const_iterator fitr=m_foldermap.find(key);
466  if (fitr==m_foldermap.end()) {
468  "updateAddress cannot find description for TAD " << key );
469  return StatusCode::FAILURE;
470  }
471  IOVDbFolder* folder=fitr->second;
472  if (folder->clid()!=tad->clID()) {
473  ATH_MSG_VERBOSE( "CLID for TAD " << key << " is " << tad->clID()
474  << " but expecting " << folder->clid() );
475 
476  return StatusCode::FAILURE;
477  }
478 
479  // IOVDbSvc will satisfy the request, using already found folder
480  // now determine the current IOVTime
482  ATH_MSG_DEBUG( "updateAddress: in initialisation phase and no iovTime defined" );
483  return::StatusCode::SUCCESS;
484  }
486  // determine iovTime from eventID in the event context
487  const EventIDBase* evid = EventIDFromStore( m_h_sgSvc );
488  if( evid ) {
489  iovTime.setRunEvent( evid->run_number(), evid->lumi_block()) ;
490  // save both seconds and ns offset for timestamp
491  uint64_t nsTime = evid->time_stamp() *1000000000LL;
492  nsTime += evid->time_stamp_ns_offset();
493  iovTime.setTimestamp(nsTime);
494  m_iovTime = iovTime;
495  ATH_MSG_DEBUG( "updateAddress - using iovTime from EventInfo: " << iovTime);
496  } else {
497  // failed to get event info - just return success
498  ATH_MSG_DEBUG( "Could not get event - initialise phase");
499  return StatusCode::SUCCESS;
500  }
501  } else {
502  ATH_MSG_DEBUG("updateAddress: using iovTime from init/beginRun: " << iovTime);
503  }
504 
505 
506 
507  // obtain the validity key for this folder (includes overrides)
508  cool::ValidityKey vkey=folder->iovTime(iovTime);
509  {
510  // The dblock is currently abused to also protect the cache in the IOVDbFolders.
511  // This global lock may give rise to deadlocks between the dblock and the internal lock
512  // of the SGImplSvc. The deadlock may arise if the order of the initial call to IOVDbSvc
513  // and SGImplSvc are different, because the two services call each other.
514  // A problem was observed when SG::DataProxy::isValidAddress first called IOVDbSvc::updateAddress
515  // which called IOVSvc::setRange then SGImplSvc::proxy, and at the same time
516  // StoreGateSvc::contains called first SGImplSvc::proxy which then called IOVDbSvc::updateAddress.
517  // This problem is mitigated by limiting the scope of the dblock here.
518  Athena::DBLock dblock;
519  ATH_MSG_DEBUG("Validity key "<<vkey);
520  if (!folder->readMeta() && !folder->cacheValid(vkey)) {
521  // mark this folder as not-dropped so cache-read will succeed
522  folder->setDropped(false);
523  // reload cache for this folder (and all others sharing this DB connection)
524  ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName());
525  if (StatusCode::SUCCESS!=loadCaches(folder->conn())) {
526  ATH_MSG_ERROR( "Cache load failed for at least one folder from " << folder->conn()->name()
527  << ". You may see errors from other folders sharing the same connection." );
528  return StatusCode::FAILURE;
529  }
530  }
531 
532  // data should now be in cache
533  // setup address and range
534  {
535  Gaudi::Guards::AuditorGuard auditor(std::string("FldrSetup:")+(tad->name().empty() ? "anonymous" : tad->name()),
536  auditorSvc(), "preLoadProxy");
537  if (!folder->getAddress(vkey,&(*m_h_persSvc),poolSvcContext(),address,
539  ATH_MSG_ERROR( "getAddress failed for folder " << folder->folderName() );
540  return StatusCode::FAILURE;
541  }
542  }
543  // reduce minimum IOV of timestamp folders to avoid 'thrashing'
544  // due to events slightly out of order in HLT
545  if (folder->timeStamp()) {
546  cool::ValidityKey start=range.start().timestamp();
548  range=IOVRange(IOVTime(start),range.stop());
549  }
550  }
551 
552  // Pass range onto IOVSvc
553  if (StatusCode::SUCCESS!=m_h_IOVSvc->setRange(tad->clID(),tad->name(),
554  range,folder->eventStore())) {
555  ATH_MSG_ERROR( "setRange failed for folder " << folder->folderName() );
556  return StatusCode::FAILURE;
557  }
558  tad->setAddress(address.release());
559  return StatusCode::SUCCESS;
560 }
561 
562 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
563 
565  const std::string& dbKey,
566  const IOVTime& time,
567  IOVRange& range,
568  std::string& tag,
569  std::unique_ptr<IOpaqueAddress>& address) {
570 
571  Athena::DBLock dblock;
572 
573  ATH_MSG_DEBUG( "getRange clid: " << clid << " key: \""<< dbKey << "\" t: " << time );
574  const std::string& key=dbKey;
575  FolderMap::const_iterator fitr=m_foldermap.find(key);
576  if (fitr==m_foldermap.end()) {
577  ATH_MSG_VERBOSE("getRange cannot find description for dbKey " << key );
578  return StatusCode::FAILURE;
579  }
580  IOVDbFolder* folder=fitr->second;
581  if (folder->clid()!=clid) {
582  ATH_MSG_VERBOSE( "supplied CLID for " << key << " is "
583  << clid
584  << " but expecting " << folder->clid() );
585 
586  return StatusCode::FAILURE;
587  }
588 
589  tag = folder->key();
590 
591  // obtain the validity key for this folder (includes overrides)
592  cool::ValidityKey vkey=folder->iovTime(time);
593  if (!folder->readMeta() && !folder->cacheValid(vkey)) {
594  // mark this folder as not-dropped so cache-read will succeed
595  folder->setDropped(false);
596  // reload cache for this folder (and all others sharing this DB connection)
597  ATH_MSG_DEBUG( "Triggering cache load for folder " << folder->folderName() );
598  if (StatusCode::SUCCESS!=loadCaches(folder->conn(),&time)) {
599  ATH_MSG_ERROR( "Cache load failed for at least one folder from " << folder->conn()->name()
600  << ". You may see errors from other folders sharing the same connection." );
601  return StatusCode::FAILURE;
602  }
603  }
604 
605  // data should now be in cache
606  address.reset();
607  // setup address and range
608  {
609  Gaudi::Guards::AuditorGuard auditor(std::string("FldrSetup:")+(key.empty() ? "anonymous" : key),
610  auditorSvc(), "preLoadProxy");
611  if (!folder->getAddress(vkey,&(*m_h_persSvc),poolSvcContext(),address,
613  ATH_MSG_ERROR("getAddress failed for folder " <<folder->folderName() );
614  return StatusCode::FAILURE;
615  }
616  }
617 
618  // Special handling for extensible folders:
619  if (folder->extensible()) {
620  // Set the end time to just past the current event or lumiblock.
621  IOVTime extStop = range.stop();
622  if (folder->timeStamp()) {
623  extStop.setTimestamp (time.timestamp() + 1);
624  }
625  else {
626  extStop.setRETime (time.re_time() + 1);
627  }
628  range = IOVRange (range.start(), extStop);
629  }
630 
631  // Special handling for IOV override: set the infinite validity range
632  if (folder->iovOverridden()) {
633  if (folder->timeStamp()) {
636  }
637  else {
640  }
641  }
642 
643  return StatusCode::SUCCESS;
644 }
645 
646 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
647 
649  const std::string& /*dbKey*/,
650  const IOVRange& /*range*/,
651  const std::string& /*storeName*/ ) {
652  // this method does nothing
653  return StatusCode::SUCCESS;
654 }
655 
657  const EventContext& ctx)
658 {
659  Athena::DBLock dblock;
660 
661  // Begin run - set state and save time for later use
663  // Is this a different run compared to the previous call?
664  bool newRun = m_iovTime.isValid() && (m_iovTime.run() != beginRunTime.run());
665  m_iovTime=beginRunTime;
666  // For a MC event, the run number we need to use to look up the conditions
667  // may be different from that of the event itself. Override the run
668  // number with the conditions run number from the event context,
669  // if it is defined.
670  EventIDBase::number_type conditionsRun =
672  if (conditionsRun != EventIDBase::UNDEFNUM) {
673  m_iovTime.setRunEvent (conditionsRun, m_iovTime.event());
674  }
675 
676  ATH_MSG_DEBUG( "signalBeginRun> begin run time " << m_iovTime);
677  if (!m_par_onlineMode) {
678  return StatusCode::SUCCESS;
679  }
680 
681  // ONLINE mode: allow adding of new calibration constants between runs
682  if (!newRun) {
683  ATH_MSG_DEBUG( "Same run as previous signalBeginRun call. Skipping re-loading of folders..." );
684  return StatusCode::SUCCESS;
685  }
686 
687  // all other stuff is event based so happens after this.
688  // this is before first event of each run
689  ATH_MSG_DEBUG( "In online mode will recheck ... " );
690  ATH_MSG_DEBUG( "First reload PoolCataloge ... " );
691 
692  pool::IFileCatalog* catalog ATLAS_THREAD_SAFE = // we are not within the event loop yet
693  const_cast<pool::IFileCatalog*>(m_h_poolSvc->catalog());
694  catalog->commit();
695  catalog->start();
696 
697  for (const auto & pThisConnection : m_connections){
698  // only access connections which are actually in use - avoids waking up
699  // the default DB connection if it is not being used
700  if (pThisConnection->nFolders()>0) {
701  //request for database activates connection
702  cool::IDatabasePtr dbconn=pThisConnection->getCoolDb();
703  if (dbconn.get()==nullptr) {
704  ATH_MSG_FATAL( "Conditions database connection " << pThisConnection->name() << " cannot be opened - STOP" );
705  return StatusCode::FAILURE;
706  }
707  for (const auto & thisNamePtrPair: m_foldermap) {
708  IOVDbFolder* folder=thisNamePtrPair.second;
709  if (folder->conn()!=pThisConnection) continue;
710  folder->printCache();
711  cool::ValidityKey vkey=folder->iovTime(m_iovTime);
712  {
713  Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
714  if (!folder->loadCacheIfDbChanged(vkey, m_globalTag, dbconn, m_h_IOVSvc)) {
715  ATH_MSG_ERROR( "Problem RELOADING: " << folder->folderName());
716  return StatusCode::FAILURE;
717  }
718  }
719  folder->printCache();
720  }
721  }
722  if (m_par_manageConnections) pThisConnection->setInactive();
723  }
724  return StatusCode::SUCCESS;
725 }
726 
728  // this method does nothing
729 }
730 
732  // Close any open POOL files after loding Conditions
733  ATH_MSG_DEBUG( "postConditionsLoad: m_par_managePoolConnections=" << m_par_managePoolConnections
734  << " m_poolPayloadRequested=" << m_poolPayloadRequested );
735 
737  // reset POOL connection to close all open conditions POOL files
738  m_par_managePoolConnections.set(false);
740  if( m_poolSvcContext ) {
741  if (StatusCode::SUCCESS==m_h_poolSvc->disconnect(m_poolSvcContext)) {
742  ATH_MSG_DEBUG( "Successfully closed input POOL connections");
743  } else {
744  ATH_MSG_WARNING( "Unable to close input POOL connections" );
745  }
746  // reopen transaction
747  if (StatusCode::SUCCESS==m_h_poolSvc->connect(pool::ITransaction::READ, m_poolSvcContext)) {
748  ATH_MSG_DEBUG("Reopend read transaction for POOL conditions input files" );
749  } else {
750  ATH_MSG_WARNING("Cannot reopen read transaction for POOL conditions input files");
751  }
752  }
753  }
754 }
755 
756 void IOVDbSvc::handle( const Incident& inc) {
757  // Handle incidents:
758  // BeginEvent to set IOVDbSvc state to EVENT_LOOP
759  // StoreCleared/EndProcessing to close any open POOL files
760  ATH_MSG_VERBOSE( "entering handle(), incident type " << inc.type() << " from " << inc.source() );
761  if (inc.type()=="BeginEvent") {
763  } else {
764  Athena::DBLock dblock;
765 
766  const StoreClearedIncident* sinc = dynamic_cast<const StoreClearedIncident*>(&inc);
767  if( (inc.type()=="StoreCleared" && sinc!=nullptr && sinc->store()==&*m_h_sgSvc
769  or inc.type()==IncidentType::EndProcessing )
770  {
773  }
774  }
775 }
776 
778  // Processing of taginfo
779  // Set GlobalTag and any folder-specific overrides if given
780 
781  // dump out contents of TagInfo
782  ATH_MSG_DEBUG( "Tags from input TagInfo:");
783  if( msg().level()>=MSG::DEBUG ) m_h_tagInfoMgr->printTags(msg());
784 
785  // check IOVDbSvc GlobalTag, if not already set
786  if (m_globalTag.empty()) {
787  m_globalTag = m_h_tagInfoMgr->findTag("IOVDbGlobalTag");
788  if (!m_globalTag.empty()) ATH_MSG_INFO( "Global tag: " << m_globalTag<< " set from input file" );
790  }
791 
792  // now check for tag overrides for specific folders
793  const ITagInfoMgr::NameTagPairVec nameTagPairs = m_h_tagInfoMgr->getInputTags();
794  for (const auto & thisNameTagPair: nameTagPairs) {
795  // assume tags relating to conditions folders start with /
796  if (not refersToConditionsFolder(thisNameTagPair)) continue;
797  // check for folder(s) with this name in (key, ptr) pair
798  for (const auto & thisKeyPtrPair: m_foldermap) {
799  IOVDbFolder* folder=thisKeyPtrPair.second;
800  const std::string& ifname=folder->folderName();
801  if (ifname!=thisNameTagPair.first) continue;
802  // use an override from TagInfo only if there is not an explicit jo tag,
803  // and folder meta-data is not used, and there is no <noover/> spec,
804  // and no global tag set in job options
805  const auto & theTag{thisNameTagPair.second};
806  if (folder->joTag().empty() && !folder->readMeta() && !folder->noOverride() && m_par_globalTag.empty()) {
807  folder->setTagOverride(theTag,false);
808  ATH_MSG_INFO( "TagInfo override for tag " << theTag << " in folder " << ifname );
809  } else if (folder->joTag()!=theTag) {
810  const std::string_view tagTypeString=(folder->joTag().empty()) ? "hierarchical" : "jobOption";
811  ATH_MSG_INFO( "Ignoring inputfile TagInfo request for tag " << theTag << " in folder " << ifname<<" in favour of "<<tagTypeString);
812  }
813  }
814  }
815  return StatusCode::SUCCESS;
816 }
817 
818 std::vector<std::string>
820  // return a list of all the StoreGate keys being managed by IOVDbSvc
821  std::vector<std::string> keys;
822  keys.reserve(m_foldermap.size());
823  std::for_each(m_foldermap.begin(),m_foldermap.end(), [&keys](const auto &i){keys.emplace_back(i.first);});
824  return keys;
825 }
826 
827 bool IOVDbSvc::getKeyInfo(const std::string& key, IIOVDbSvc::KeyInfo& info) {
828  // return information about given SG key
829  // first attempt to find the folder object for this key
830  FolderMap::const_iterator itr = m_foldermap.find(key);
831  if (itr!=m_foldermap.end()) {
832  const IOVDbFolder* f=itr->second;
833  info.folderName = f->folderName();
834  info.tag = f->resolvedTag();
835  info.range = f->currentRange();
836  info.retrieved = f->retrieved();
837  info.bytesRead = f->bytesRead();
838  info.readTime = f->readTime();
839  info.extensible = f->extensible();
840  return true;
841  } else {
842  info.retrieved = false;
843  return false;
844  }
845 }
846 
847 bool IOVDbSvc::dropObject(const std::string& key, const bool resetCache) {
848  // find the folder corresponding to this object
849  FolderMap::const_iterator itr=m_foldermap.find(key);
850  if (itr!=m_foldermap.end()) {
851  IOVDbFolder* folder=itr->second;
852  CLID clid=folder->clid();
853  SG::DataProxy* proxy=m_h_detStore->proxy(clid,key);
854  if (proxy!=nullptr) {
855  m_h_detStore->clearProxyPayload(proxy);
856  ATH_MSG_DEBUG("Dropped payload for key " << key );
857  folder->setDropped(true);
858  if (resetCache) {
859  folder->resetCache();
860  ATH_MSG_DEBUG( "Cache reset done for folder " << folder->folderName() );
861  }
862  return true;
863  } else {
864  return false;
865  }
866  } else {
867  return false;
868  }
869 }
870 
871 
872 /************************/
873 // private methods of IOVDbSvc
874 
876  // check if EventSelector is being used to override run numbers
877  // if so, we can set IOV time already to allow conditons retrieval
878  // in the initialise phase, needed for setting up simulation
879 
880  ServiceHandle<Gaudi::Interfaces::IOptionsSvc> joSvc("JobOptionsSvc",name());
881  ATH_CHECK( joSvc.retrieve() );
882 
883  if (!joSvc->has("EventSelector.OverrideRunNumber")) {
884  // do not return FAILURE if the EventSelector cannot be found, or it has
885  // no override property, can e.g. happen in online running
886  ATH_MSG_DEBUG( "No EventSelector.OverrideRunNumber property found" );
887  return StatusCode::SUCCESS;
888  }
889 
890  BooleanProperty bprop("OverrideRunNumber",false);
891  ATH_CHECK( bprop.fromString(joSvc->get("EventSelector.OverrideRunNumber")) );
892  if (bprop.value()) {
893  // if flag is set, extract Run,LB and time
894  ATH_MSG_INFO( "Setting run/LB/time from EventSelector override in initialize" );
895  uint32_t run,lumib;
896  uint64_t time;
897  bool allGood=true;
898  if (m_par_forceRunNumber.value()!=0 ||
899  m_par_forceLumiblockNumber.value()!=0)
900  ATH_MSG_WARNING( "forceRunNumber property also set" );
901  IntegerProperty iprop1("RunNumber",0);
902  if (iprop1.fromString(joSvc->get("EventSelector.RunNumber","INVALID"))) {
903  run=iprop1.value();
904  } else {
905  ATH_MSG_ERROR( "Unable to get RunNumber from EventSelector");
906  allGood=false;
907  }
908  IntegerProperty iprop2("FirstLB",0);
909  if (iprop2.fromString(joSvc->get("EventSelector.FirstLB","INVALID"))) {
910  lumib=iprop2.value();
911  } else {
912  ATH_MSG_ERROR( "Unable to get FirstLB from EventSelector");
913  allGood=false;
914  }
915  IntegerProperty iprop3("InitialTimeStamp",0);
916  if (iprop3.fromString(joSvc->get("EventSelector.InitialTimeStamp","INVALID"))) {
917  time=iprop3.value();
918  } else {
919  ATH_MSG_ERROR("Unable to get InitialTimeStamp from EventSelector" );
920  allGood=false;
921  }
922  if (allGood) {
923  m_iovTime.setRunEvent(run,lumib);
924  uint64_t nsTime=time*1000000000LL;
925  m_iovTime.setTimestamp(nsTime);
926  ATH_MSG_INFO( "run/LB/time set to [" << run << "," << lumib << " : " << nsTime << "]" );
927  } else {
928  ATH_MSG_ERROR( "run/LB/Time NOT changed" );
929  }
930  }
931 
932  return StatusCode::SUCCESS;
933 }
934 
936  // read the Folders joboptions and setup the folder list
937  // no wildcards are allowed
938 
939  // getting the pairs: folder name - CREST tag name:
940  if (m_par_source == "CREST"){
941  m_cresttagmap.clear();
943  }
944 
945  //1. Loop through folders
946  std::list<IOVDbParser> allFolderdata;
947  for (const auto & thisFolder : m_par_folders.value()) {
948  ATH_MSG_DEBUG( "Setup folder " << thisFolder );
949  IOVDbParser folderdata(thisFolder,msg());
950  if (!folderdata.isValid()) {
951  ATH_MSG_FATAL("setupFolders: Folder setup string is invalid: " <<thisFolder);
952  return StatusCode::FAILURE;
953  }
954 
955  allFolderdata.push_back(folderdata);
956  }
957 
958  //2. Loop through overwrites:
959  // syntax for entries is <prefix>folderpath</prefix> <tag>value</tag>
960  // folderpath matches from left of folderName
961  // but if partial match, next character must be / so override for /Fred/Ji
962  // matches /Fred/Ji/A and /Fred/Ji but not /Fred/Jim
963 
964  for (const auto & thisOverrideTag : m_par_overrideTags) {
965  IOVDbParser keys(thisOverrideTag,msg());
966  if (not keys.isValid()){
967  ATH_MSG_ERROR("An override tag was invalid: " << thisOverrideTag);
968  return StatusCode::FAILURE;
969  }
970  std::string prefix;
971  if (!keys.getKey("prefix","",prefix)) { // || !keys.getKey("tag","",tag)) {
972  ATH_MSG_ERROR( "Problem in overrideTag specification " <<thisOverrideTag );
973  return StatusCode::FAILURE;
974  }
975 
976  for (auto& folderdata : allFolderdata) {
977  const std::string& ifname=folderdata.folderName();
978  if (ifname.compare(0,prefix.size(), prefix)==0 &&
979  (ifname.size()==prefix.size() || ifname[prefix.size()]=='/')) {
980  //Match!
981  folderdata.applyOverrides(keys,msg());
982  }// end if
983  }// end loop over allFolderdata
984  }// end loop over overrides
985 
986  //3. Remove any duplicates:
987  std::list<IOVDbParser>::iterator it1=allFolderdata.begin();
988  std::list<IOVDbParser>::iterator it_e=allFolderdata.end();
989  for (;it1!=it_e;++it1) {
990  const IOVDbParser& folder1=*it1;
992  ++it2;
993  while(it2!=it_e) {
994  const IOVDbParser& folder2=*it2;
995  if (folder1==folder2) {
996  it2=allFolderdata.erase(it2); //FIXME: Smarter distinction/reporting about same folder but different keys.
997  ATH_MSG_DEBUG( "Removing duplicate folder " << folder1.folderName());
998  } else {
999  ++it2;
1000  //Catch suspicous cases:
1001  if (folder1.folderName()==folder2.folderName()) {
1002  ATH_MSG_WARNING( "Folder name appears twice: " << folder1.folderName() );
1003  ATH_MSG_WARNING( folder1 << " vs " << folder2 );
1004  }
1005  }
1006  }//end inner loop
1007  }//end outer loop
1008 
1009  //4.Set up folder map with cleaned folder list
1010 
1011  bool hasError=false;
1012  for (const auto& folderdata : allFolderdata) {
1013  // find the connection specification first - db or dbConnection
1014  // default is to use the 'default' connection
1015  IOVDbConn* conn=nullptr;
1016  std::string connstr;
1017  if (folderdata.getKey("db","",connstr) ||
1018  folderdata.getKey("dbConnection","",connstr)) {
1019  // an explicit database name is specified
1020  // check if it is already present in the existing connections
1021  for (const auto & pThisConnection : m_connections) {
1022  if (pThisConnection->name()==connstr) {
1023  // found existing connection - use that
1024  conn=pThisConnection;
1025  break;
1026  }
1027  }
1028  if (conn==nullptr) {
1029  // create new read-onlyconnection
1030  conn=new IOVDbConn(connstr,true,msg());
1031  m_connections.push_back(conn);
1032  }
1033  } else {
1034  // no connection specified - use default if available
1035  if (!m_par_defaultConnection.empty()) {
1036  conn=m_connections[0];
1037  } else {
1038  ATH_MSG_FATAL( "Folder request " << folderdata.folderName() <<
1039  " gives no DB connection information and no default set" );
1040  return StatusCode::FAILURE;
1041  }
1042  }
1043 
1044  // create the new folder, but only if a folder for this SG key has not
1045  // already been requested
1046 
1047  std::string crestTag = "";
1048  if (m_par_source == "CREST"){
1049  crestTag = m_cresttagmap[folderdata.folderName()];
1050  if(crestTag.size()==0 && folderdata.folderName().compare("/TagInfo")!=0){
1051  ATH_MSG_FATAL( "Global Tag "<<m_par_globalTag<<" hasn't folder: " << folderdata.folderName() <<
1052  " in Global Tag Map." );
1053  hasError=true;
1054  continue;
1055  }
1056  }
1057 
1058  IOVDbFolder* folder=new IOVDbFolder(conn,folderdata,msg(),&(*m_h_clidSvc), &(*m_h_metaDataTool),
1060  const std::string& key=folder->key();
1061  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  conn->incUsage();
1064  } else {
1065  ATH_MSG_ERROR( "Duplicate request for folder " <<
1066  folder->folderName() <<
1067  " associated to already requested Storegate key " << key );
1068  // clean up this duplicate request
1069  delete folder;
1070  }
1071  }// end loop over folders
1072  // check for folders to be written to metadata
1073  if(hasError)
1074  return StatusCode::FAILURE;
1075  for (const auto & folderToWrite : m_par_foldersToWrite) {
1076  // match wildcard * at end of string only (i.e. /A/* matches /A/B, /A/C/D)
1077  std::string_view match=folderToWrite;
1078  std::string::size_type idx=folderToWrite.find('*');
1079  if (idx!=std::string::npos) {
1080  match=std::string_view(folderToWrite).substr(0,idx);
1081  }
1082  for (const auto & thisFolder : m_foldermap) {
1083  IOVDbFolder* fptr=thisFolder.second;
1084  if ((fptr->folderName()).compare(0,match.size(), match)==0) {
1085  fptr->setWriteMeta();
1086  ATH_MSG_INFO( "Folder " << fptr->folderName() << " will be written to file metadata" );
1087  }
1088  }//end loop over FolderMap
1089  }//end loop over m_par_foldersToWrite
1090  return StatusCode::SUCCESS;
1091 }
1092 
1094  if (!m_par_globalTag.empty()) {
1095  ATH_MSG_DEBUG( "Adding GlobalTag " << m_par_globalTag << " into TagInfo" );
1096  if (StatusCode::SUCCESS!=m_h_tagInfoMgr->addTag("IOVDbGlobalTag",m_par_globalTag))
1097  return StatusCode::FAILURE;
1098  }
1099  // add all explicit tags specified in folders
1100  // can be from Folders or tagOverrides properties
1101  for (const auto & thisFolder : m_foldermap) {
1102  const IOVDbFolder* folder=thisFolder.second;
1103  if (!folder->joTag().empty()) {
1104  ATH_MSG_DEBUG( "Adding folder " << folder->folderName() <<" tag " << folder->joTag() << " into TagInfo" );
1105  if (StatusCode::SUCCESS!=m_h_tagInfoMgr->addTag(folder->folderName(),folder->joTag()))
1106  return StatusCode::FAILURE;
1107  }
1108  // check to see if any input TagInfo folder overrides should be removed
1109  // this anticipates the decisions which will be made in processTagInfo
1110  // Here we do not have access to the TagInfo object, but can put remove
1111  // requests in for all folders if the global tag is set, or if there is
1112  // an explict joboption tag, nooverride spec, or data comes from metadata
1113  if (!m_par_globalTag.empty() || !folder->joTag().empty() || folder->noOverride() ||
1114  folder->readMeta()) {
1115  if (StatusCode::SUCCESS!=
1116  m_h_tagInfoMgr->removeTagFromInput(folder->folderName())) {
1117  ATH_MSG_WARNING( "Could not add TagInfo remove request for "
1118  << folder->folderName() );
1119  } else {
1120  ATH_MSG_INFO( "Added taginfo remove for " <<
1121  folder->folderName() );
1122  }
1123  }
1124  }
1125  return StatusCode::SUCCESS;
1126 }
1127 
1129  // load the caches for all folders using the given connection
1130  // so connection use is optimised
1131 
1132  Gaudi::Guards::AuditorGuard auditor(std::string("loadCachesOverhead:")+conn->name(), auditorSvc(), "preLoadProxy");
1133 
1134  ATH_MSG_DEBUG( "loadCaches: Begin for connection " << conn->name());
1135  // if global abort already set, load nothing
1136  if (m_abort) return StatusCode::FAILURE;
1137  bool access=false;
1138  StatusCode sc=StatusCode::SUCCESS;
1139  for (const auto & thisNamePtrPair : m_foldermap) {
1140  IOVDbFolder* folder=thisNamePtrPair.second;
1141  if (folder->conn()!=conn) continue;
1142  cool::ValidityKey vkey=folder->iovTime(time==nullptr ? m_iovTime : *time);
1143  // protect against out of range times (timestamp -1 happened in FDR2)
1144  if (vkey>cool::ValidityKeyMax) {
1145  ATH_MSG_WARNING( "Requested validity key " << vkey << " is out of range, reset to 0" );
1146  vkey=0;
1147  }
1148  if (!folder->cacheValid(vkey) && !folder->dropped()) {
1149  access=true;
1150  {
1151  Gaudi::Guards::AuditorGuard auditor(std::string("FldrCache:")+folder->folderName(), auditorSvc(), "preLoadProxy");
1152  if (!folder->loadCache(vkey,m_par_cacheAlign,m_globalTag,m_par_onlineMode)) {
1153  ATH_MSG_ERROR( "Cache load (prefetch) failed for folder " << folder->folderName() );
1154  // remember the failure, but also load other folders on this connection
1155  // while it is open
1156  sc=StatusCode::FAILURE;
1157  }
1158  }
1159  }
1160  }
1161  // disconnect from database if we connected
1162  if (access && m_par_manageConnections) conn->setInactive();
1163  // if connection aborted, set overall abort so we do not waste time trying
1164  // to read data from other schema
1165  if (conn->aborted()) {
1166  ATH_MSG_FATAL( "Connection " << conn->name() << " was aborted, set global abort" );
1167  m_abort=true;
1168  ATH_MSG_FATAL( "loadCache: impossible to load cache!" );
1169  throw std::exception();
1170  }
1171  return sc;
1172 }
1173 
1175 // check consistency of global tag and database instance, if set
1176  // catch most common user misconfigurations
1177  // this is only done here as need global tag to be set even if read from file
1178  // @TODO should this not be done during initialize
1179  if (!m_par_dbinst.empty() && !m_globalTag.empty() and (m_par_source!="CREST")) {
1180  const std::string_view tagstub=std::string_view(m_globalTag).substr(0,7);
1181  ATH_MSG_DEBUG( "Checking " << m_par_dbinst << " against " <<tagstub );
1182  if (((m_par_dbinst=="COMP200" || m_par_dbinst=="CONDBR2") &&
1183  (tagstub!="COMCOND" && tagstub!="CONDBR2")) ||
1184  (m_par_dbinst=="OFLP200" && (tagstub!="OFLCOND" && tagstub!="CMCCOND"))) {
1185  ATH_MSG_FATAL( "Likely incorrect conditions DB configuration! "
1186  << "Attached to database instance " << m_par_dbinst <<
1187  " but global tag begins " << tagstub );
1188  ATH_MSG_FATAL( "See Atlas/CoolTroubles wiki for details," <<
1189  " or set IOVDbSvc.DBInstance=\"\" to disable check" );
1190  return StatusCode::FAILURE;
1191  }
1192  }
1193  return StatusCode::SUCCESS;
1194 }
IOVDbSvc::postConditionsLoad
virtual void postConditionsLoad() override
May be called once conditions are loaded to let IOVDbSvc release resources.
Definition: IOVDbSvc.cxx:731
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
IOVDbSvc::initialize
virtual StatusCode initialize() override
Service init.
Definition: IOVDbSvc.cxx:160
IOVDbFolder.h
IOVDbSvc::INITIALIZATION
@ INITIALIZATION
Definition: IOVDbSvc.h:260
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:315
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:827
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:407
IOVTime::MAXRUN
static constexpr uint32_t MAXRUN
Definition: IOVTime.h:48
IOVDbSvc::m_crestCoolToFile
BooleanProperty m_crestCoolToFile
Definition: IOVDbSvc.h:231
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:283
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:1093
IOVDbSvc::getDatabase
virtual cool::IDatabasePtr getDatabase(bool readOnly) override
Access to COOL database for a given folder.
Definition: IOVDbSvc.cxx:297
initialize
void initialize()
Definition: run_EoverP.cxx:894
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:13
CscCalibQuery.fullPath
string fullPath
Definition: CscCalibQuery.py:359
IFileCatalog.h
IOVDbSvc::m_par_maxNumPoolFiles
IntegerProperty m_par_maxNumPoolFiles
Definition: IOVDbSvc.h:207
SG::TransientAddress
Definition: TransientAddress.h:32
run
int run(int argc, char *argv[])
Definition: ttree2hdf5.cxx:28
IOVDbSvc::poolSvcContext
int poolSvcContext()
Definition: IOVDbSvc.cxx:141
IOVDbSvc::signalEndProxyPreload
virtual void signalEndProxyPreload() override
Signal that callback has been fired.
Definition: IOVDbSvc.cxx:727
IOVDbSvc::m_foldermap
FolderMap m_foldermap
Definition: IOVDbSvc.h:281
AtlasMcWeight::number_type
unsigned int number_type
Definition: AtlasMcWeight.h:20
IOVDbSvc::m_h_poolSvc
ServiceHandle< IPoolSvc > m_h_poolSvc
Definition: IOVDbSvc.h:240
pool::IFileCatalog::commit
void commit()
Save catalog to file.
Definition: IFileCatalog.h:49
IOVDbSvc::m_par_timeStampSlop
FloatProperty m_par_timeStampSlop
Definition: IOVDbSvc.h:209
IOVDbSvc::dropObject
virtual bool dropObject(const std::string &key, const bool resetCache=false) override
Definition: IOVDbSvc.cxx:847
IOVDbSvc::io_reinit
StatusCode io_reinit() override final
Definition: IOVDbSvc.cxx:246
IOVDbSvc::tadList
IAddressProvider::tadList tadList
Definition: IOVDbSvc.h:102
IOVDbSvc::m_par_manageConnections
BooleanProperty m_par_manageConnections
Definition: IOVDbSvc.h:197
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:90
IOVDbFolder
Definition: IOVDbFolder.h:50
IOVDbSvc::FINALIZE_ALG
@ FINALIZE_ALG
Definition: IOVDbSvc.h:263
IOVDbSvc::m_h_metaDataStore
ServiceHandle< StoreGateSvc > m_h_metaDataStore
Definition: IOVDbSvc.h:237
CoralCrestManager::getGlobalTagMap
static std::map< std::string, std::string > getGlobalTagMap(const std::string &crest_path, const std::string &globaltag)
Definition: CoralCrestManager.cxx:57
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:239
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:217
IOVDbSvc::m_par_forceRunNumber
IntegerProperty m_par_forceRunNumber
Definition: IOVDbSvc.h:201
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:648
IOVDbSvc::m_par_forceLumiblockNumber
IntegerProperty m_par_forceLumiblockNumber
Definition: IOVDbSvc.h:203
lumiFormat.i
int i
Definition: lumiFormat.py:85
IOVDbSvc::BEGIN_RUN
@ BEGIN_RUN
Definition: IOVDbSvc.h:261
IOVDbSvc::processTagInfo
virtual StatusCode processTagInfo() override
Process TagInfo.
Definition: IOVDbSvc.cxx:777
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:447
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
IOVDbSvc::m_par_cacheAlign
UnsignedIntegerProperty m_par_cacheAlign
Definition: IOVDbSvc.h:216
IOVDbSvc::m_par_crestServer
StringProperty m_par_crestServer
Definition: IOVDbSvc.h:224
IOVTime::reset
void reset() noexcept
Definition: IOVTime.cxx:108
SG::TransientAddress::clID
CLID clID() const
Retrieve string key:
Definition: TransientAddress.h:210
IOVDbSvc::m_poolSvcContext
int m_poolSvcContext
Definition: IOVDbSvc.h:251
IOVDbParser.h
calibdata.exception
exception
Definition: calibdata.py:495
IOVDbSvc::checkEventSel
StatusCode checkEventSel()
Definition: IOVDbSvc.cxx:875
ITagInfoMgr::NameTagPair
std::pair< std::string, std::string > NameTagPair
Definition: ITagInfoMgr.h:65
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:194
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:226
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:199
IOVDbSvc::m_par_defaultConnection
Gaudi::Property< std::string > m_par_defaultConnection
Definition: IOVDbSvc.h:185
hist_file_dump.f
f
Definition: hist_file_dump.py:140
IOVTime::setRETime
void setRETime(uint64_t time) noexcept
Definition: IOVTime.cxx:84
IOVDbSvc::getKeyList
virtual std::vector< std::string > getKeyList() override
Definition: IOVDbSvc.cxx:819
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:242
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:218
IOVDbSvc::m_iovTime
IOVTime m_iovTime
Definition: IOVDbSvc.h:268
StoreID::DETECTOR_STORE
@ DETECTOR_STORE
Definition: StoreID.h:27
IOVDbConn::setInactive
void setInactive()
Definition: IOVDbConn.cxx:114
IOVDbSvc::m_connections
ConnVec m_connections
Definition: IOVDbSvc.h:278
IOVTime::MAXEVENT
static constexpr uint32_t MAXEVENT
Definition: IOVTime.h:51
IOVDbSvc::FolderMap
std::map< std::string, IOVDbFolder * > FolderMap
Definition: IOVDbSvc.h:280
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:220
IOVDbSvc::handle
virtual void handle(const Incident &incident) override
Incident service handle for EndEvent.
Definition: IOVDbSvc.cxx:756
IOVDbConn
Definition: IOVDbConn.h:18
dumpBeamSpot.dbconn
dbconn
Definition: dumpBeamSpot.py:26
IOVDbSvc::io_finalize
StatusCode io_finalize() override final
Definition: IOVDbSvc.cxx:253
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
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:193
IOVDbSvc::m_outputToFile
BooleanProperty m_outputToFile
Definition: IOVDbSvc.h:230
IOVDbSvc::m_state
IOVDbSvc_state m_state
Definition: IOVDbSvc.h:265
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:238
IOVTime::MINEVENT
static constexpr uint32_t MINEVENT
Definition: IOVTime.h:50
IOVDbSvc::m_par_cacheRun
IntegerProperty m_par_cacheRun
Definition: IOVDbSvc.h:211
SG::TransientAddress::setAddress
void setAddress(IOpaqueAddress *pAddress)
Retrieve primary clid.
Definition: TransientAddress.cxx:194
fillPileUpNoiseLumi.createFolder
def createFolder(db, name)
Definition: fillPileUpNoiseLumi.py:6
IOVDbSvc::EVENT_LOOP
@ EVENT_LOOP
Definition: IOVDbSvc.h:262
python.Dumpers.tlist
list tlist
Definition: Dumpers.py:5527
python.AthDsoLogger.fname
string fname
Definition: AthDsoLogger.py:66
IOVDbSvc::m_par_globalTag
Gaudi::Property< std::string > m_par_globalTag
Definition: IOVDbSvc.h:187
IOVDbSvc::m_par_dbinst
Gaudi::Property< std::string > m_par_dbinst
Definition: IOVDbSvc.h:189
CoralCrestManager.h
Header for CoralCrestManager class.
IOVDbSvc::m_poolPayloadRequested
bool m_poolPayloadRequested
Definition: IOVDbSvc.h:247
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:564
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:191
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:55
IIOVDbSvc::KeyInfo
Filled by IIOVDbSvc::getKeyInfo.
Definition: IIOVDbSvc.h:44
IAddressProvider.h
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:801
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:23
makeDTCalibBlob_pickPhase.theTag
def theTag
Definition: makeDTCalibBlob_pickPhase.py:384
IOVDbSvc::m_h_detStore
ServiceHandle< StoreGateSvc > m_h_detStore
Definition: IOVDbSvc.h:236
IOVDbSvc::m_iovslop
cool::ValidityKey m_iovslop
Definition: IOVDbSvc.h:274
IOVDbSvc::loadCaches
StatusCode loadCaches(IOVDbConn *conn, const IOVTime *time=nullptr)
Definition: IOVDbSvc.cxx:1128
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:935
IOVDbSvc::m_h_IOVSvc
ServiceHandle< IIOVSvc > m_h_IOVSvc
Definition: IOVDbSvc.h:234
StoreGateSvc.h
SG::ConstIterator
Definition: SGIterator.h:164
IOVDbSvc::signalBeginRun
virtual StatusCode signalBeginRun(const IOVTime &beginRunTime, const EventContext &ctx) override
Set time for begin run.
Definition: IOVDbSvc.cxx:656
python.ParticleTypeUtil.info
def info
Definition: ParticleTypeUtil.py:87
IOVDbSvc::m_par_source
StringProperty m_par_source
Definition: IOVDbSvc.h:222
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
IOVDbSvc::m_h_sgSvc
ServiceHandle< StoreGateSvc > m_h_sgSvc
Definition: IOVDbSvc.h:235
IOVDbSvc::m_par_foldersToWrite
Gaudi::Property< std::vector< std::string > > m_par_foldersToWrite
Definition: IOVDbSvc.h:195
IOVDbSvc::m_globalTag
std::string m_globalTag
Definition: IOVDbSvc.h:271
IOVDbSvc::loadAddresses
virtual StatusCode loadAddresses(StoreID::type storeID, tadList &list) override
Get all new addresses from Provider for this Event.
Definition: IOVDbSvc.cxx:441
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:241
IOVDbSvc::m_par_forceTimestamp
IntegerProperty m_par_forceTimestamp
Definition: IOVDbSvc.h:205
IOVDbSvc::checkConfigConsistency
StatusCode checkConfigConsistency() const
Definition: IOVDbSvc.cxx:1174
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:213
StoreClearedIncident
Incident sent after a store is cleared.
Definition: StoreClearedIncident.h:30