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