From 1c34404d7b45e86564bd25e583b02bded7ea11b3 Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Mon, 25 Feb 2019 14:43:36 +0000
Subject: [PATCH] RootStorageSvc+StorageSvc: Disable file aging for xAOD files.

---
 Database/APR/RootStorageSvc/src/RootTreeContainer.cpp | 9 ++++++++-
 Database/APR/StorageSvc/src/DbDatabaseObj.cpp         | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp
index 6fb41a4ed72..7e2fadebf1c 100755
--- a/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp
+++ b/Database/APR/RootStorageSvc/src/RootTreeContainer.cpp
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
 */
 
 //====================================================================
@@ -621,6 +621,13 @@ DbStatus RootTreeContainer::open( const DbDatabase& dbH,
                    }
                    dsc = BranchDesc(cl, pBranch, leaf, cl->New(), c);
                    dsc.aux_reader = RootAuxDynIO::getReaderForBranch(pBranch);
+                   if (dsc.aux_reader) {
+                     // If we set up a reader, then disable aging
+                     // for this file.  That will prevent POOL from
+                     // deleting the file while we still have
+                     // references to its branches.
+                     dbH.setAge (-10);
+                   }
                    break;
                 case DbColumn::CHAR:
                 case DbColumn::UCHAR:
diff --git a/Database/APR/StorageSvc/src/DbDatabaseObj.cpp b/Database/APR/StorageSvc/src/DbDatabaseObj.cpp
index 162ffae49bd..4e61518d7a4 100644
--- a/Database/APR/StorageSvc/src/DbDatabaseObj.cpp
+++ b/Database/APR/StorageSvc/src/DbDatabaseObj.cpp
@@ -884,7 +884,7 @@ void DbDatabaseObj::setAge(int value) {
   if ( 0 == m_info )  {
     m_fileAge = 0;
   }
-  else  {
+  else if (m_fileAge >= 0) {
     switch ( value )  {
     case 0:
       m_fileAge = 0;
-- 
GitLab