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