From 5c71f6ef994f23d9bcecf4591996273eef7b669f Mon Sep 17 00:00:00 2001
From: Vakho Tsulaia <vakhtang.tsulaia@cern.ch>
Date: Sat, 24 Oct 2020 07:31:11 +0200
Subject: [PATCH] AthenaMT condition data handling: allow overriding IOVs of
 individual folders

IOVDbSvs patched such that if IOV for a given folder is overriden,
then it sets infinite validity for the condition object fetched
from the database. As a result, the folder cache never gets updated, and the
object fetched from the database remains valid for the duration of the job.

Addresses ATEAM-649
---
 Database/IOVDbSvc/src/IOVDbFolder.h |  3 +++
 Database/IOVDbSvc/src/IOVDbSvc.cxx  | 12 +++++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/Database/IOVDbSvc/src/IOVDbFolder.h b/Database/IOVDbSvc/src/IOVDbFolder.h
index dfa61810121..518986e784f 100644
--- a/Database/IOVDbSvc/src/IOVDbFolder.h
+++ b/Database/IOVDbSvc/src/IOVDbFolder.h
@@ -64,6 +64,7 @@ public:
   // in subsequent events.
   bool extensible() const;
   bool dropped() const;
+  bool iovOverridden() const;
   const std::string& joTag() const;
   const std::string& resolvedTag() const;
   const std::string& eventStore() const;
@@ -316,6 +317,8 @@ inline bool IOVDbFolder::extensible() const { return m_extensible; }
 
 inline bool IOVDbFolder::dropped() const { return m_dropped; }
 
+inline bool IOVDbFolder::iovOverridden() const { return m_iovoverridden; }
+
 inline const std::string& IOVDbFolder::joTag() const { return m_jotag; }
 
 inline const std::string& IOVDbFolder::resolvedTag() const { return m_tag; }
diff --git a/Database/IOVDbSvc/src/IOVDbSvc.cxx b/Database/IOVDbSvc/src/IOVDbSvc.cxx
index c3f83658262..063ac457a3b 100644
--- a/Database/IOVDbSvc/src/IOVDbSvc.cxx
+++ b/Database/IOVDbSvc/src/IOVDbSvc.cxx
@@ -555,7 +555,17 @@ StatusCode IOVDbSvc::getRange( const CLID&        clid,
     range = IOVRange (range.start(), extStop);
   }
 
-
+  // Special handling for IOV override: set the infinite validity range
+  if (folder->iovOverridden()) {
+    if (folder->timeStamp()) {
+      range = IOVRange ( IOVTime(IOVTime::MINTIMESTAMP)
+			 , IOVTime(IOVTime::MAXTIMESTAMP) );
+    }
+    else {
+      range = IOVRange ( IOVTime(IOVTime::MINRUN,IOVTime::MINEVENT)
+			 , IOVTime(IOVTime::MAXRUN,IOVTime::MAXEVENT) );
+    }
+  }
 
   return StatusCode::SUCCESS;
 }
-- 
GitLab