Skip to content

Commit 7448d37

Browse files
committed
Fixes for PopCon transactions
1 parent ad17b17 commit 7448d37

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

CondCore/PopCon/src/PopCon.cc

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@ namespace popcon {
3737
if (!m_dbService.isAvailable())
3838
throw Exception("DBService not available");
3939
const std::string& connectionStr = m_dbService->session().connectionString();
40-
40+
m_dbService->forceInit();
4141
m_tag = m_dbService->tag(m_record);
4242
m_tagInfo.name = m_tag;
43-
if (m_targetConnectionString.empty())
43+
if (m_targetConnectionString.empty()) {
4444
m_targetSession = m_dbService->session();
45-
else {
45+
m_dbService->startTransaction();
46+
} else {
4647
cond::persistency::ConnectionPool connPool;
4748
connPool.setAuthenticationPath(m_authPath);
4849
connPool.setAuthenticationSystem(m_authSys);
4950
connPool.configure();
5051
m_targetSession = connPool.createSession(m_targetConnectionString);
52+
m_targetSession.transaction().start();
5153
}
52-
m_targetSession.transaction().start();
5354
if (m_targetSession.existsDatabase() && m_targetSession.existsIov(m_tag)) {
5455
cond::persistency::IOVProxy iov = m_targetSession.readIov(m_tag);
5556
m_tagInfo.size = iov.sequenceSize();
5657
if (m_tagInfo.size > 0) {
5758
m_tagInfo.lastInterval = iov.getLast();
5859
}
59-
6060
edm::LogInfo("PopCon") << "destination DB: " << connectionStr << ", target DB: "
6161
<< (m_targetConnectionString.empty() ? connectionStr : m_targetConnectionString) << "\n"
6262
<< "TAG: " << m_tag << ", last since/till: " << m_tagInfo.lastInterval.since << "/"
@@ -77,7 +77,11 @@ namespace popcon {
7777
lastTill = m_lastTill;
7878
m_dbService->closeIOV(lastTill, m_record);
7979
}
80-
m_targetSession.transaction().commit();
80+
if (m_targetConnectionString.empty()) {
81+
m_dbService->commitTransaction();
82+
} else {
83+
m_targetSession.transaction().commit();
84+
}
8185
}
8286

8387
} // namespace popcon

0 commit comments

Comments
 (0)