Skip to content

Commit

Permalink
Merge pull request #33629 from ggovi/condcore-lumicondforhlt-7.1-113X
Browse files Browse the repository at this point in the history
Bug fix for tag lock clean up at session closing time
  • Loading branch information
cmsbuild committed May 12, 2021
2 parents edcacec + 21eea22 commit b841f21
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 28 deletions.
3 changes: 1 addition & 2 deletions CondCore/CondDB/src/IOVEditor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ namespace cond {
tag, m_session->sessionHash, cond::auth::COND_SESSION_HASH_CODE, cond::auth::COND_DBTAG_LOCK_ACCESS_CODE);
if (!mylock)
cond::throwException(
"Tag \"" + tag + "\" can't be accessed for update, because it has been locked by an other session. \"" +
m_session->principalName + "\".",
"Tag \"" + tag + "\" can't be accessed for update, because it has been locked by an other session.",
"IOVEditor::load");
}
}
Expand Down
8 changes: 4 additions & 4 deletions CondCore/CondDB/src/SessionImpl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ namespace cond {
SessionImpl::~SessionImpl() { close(); }

void SessionImpl::close() {
if (coralSession.get()) {
if (isActive()) {
if (coralSession->transaction().isActive()) {
coralSession->transaction().rollback();
rollbackTransaction();
}
if (!lockedTags.empty()) {
coralSession->transaction().start(true);
startTransaction(false);
releaseTagLocks();
coralSession->transaction().commit();
commitTransaction();
}
coralSession.reset();
}
Expand Down
55 changes: 35 additions & 20 deletions CondCore/DBOutputService/test/stubs/LumiBasedUpdateAnalyzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,35 @@
#include <iostream>

LumiBasedUpdateAnalyzer::LumiBasedUpdateAnalyzer(const edm::ParameterSet& iConfig)
: m_record(iConfig.getParameter<std::string>("record")) {}
LumiBasedUpdateAnalyzer::~LumiBasedUpdateAnalyzer() {
std::cout << "LumiBasedUpdateAnalyzer::~LumiBasedUpdateAnalyzer" << std::endl;
: m_record(iConfig.getParameter<std::string>("record")), m_ret(-2) {}

LumiBasedUpdateAnalyzer::~LumiBasedUpdateAnalyzer() {}

void LumiBasedUpdateAnalyzer::beginJob() {
edm::Service<cond::service::OnlineDBOutputService> mydbservice;
if (!mydbservice.isAvailable()) {
return;
}
mydbservice->lockRecords();
}
void LumiBasedUpdateAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
std::cout << "LumiBasedUpdateAnalyzer::analyze " << std::endl;

void LumiBasedUpdateAnalyzer::endJob() {
edm::Service<cond::service::OnlineDBOutputService> mydbservice;
if (mydbservice.isAvailable()) {
mydbservice->releaseLocks();
}
}

void LumiBasedUpdateAnalyzer::beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg,
const edm::EventSetup& context) {
edm::Service<cond::service::OnlineDBOutputService> mydbservice;
if (!mydbservice.isAvailable()) {
std::cout << "Service is unavailable" << std::endl;
return;
}
mydbservice->logger().start();
if (!m_tagLocks) {
mydbservice->lockRecords();
m_tagLocks = true;
}
::sleep(2);
//unsigned int irun = evt.id().run();
unsigned int irun = evt.getLuminosityBlock().run();
unsigned int lumiId = evt.getLuminosityBlock().luminosityBlock();
unsigned int irun = lumiSeg.getRun().run();
unsigned int lumiId = lumiSeg.luminosityBlock();
std::string tag = mydbservice->tag(m_record);
std::cout << "tag " << tag << std::endl;
std::cout << "run " << irun << std::endl;
Expand All @@ -39,20 +48,26 @@ void LumiBasedUpdateAnalyzer::analyze(const edm::Event& evt, const edm::EventSet
mybeamspot.SetType(int(lumiId));
std::cout << mybeamspot.GetBeamType() << std::endl;
mydbservice->logger().logDebug() << "BeamType: " << mybeamspot.GetBeamType();
int ret = 0;
m_ret = 0;
try {
mydbservice->writeForNextLumisection(&mybeamspot, m_record);
} catch (const std::exception& e) {
std::cout << "Error:" << e.what() << std::endl;
mydbservice->logger().logError() << e.what();
ret = -1;
m_ret = -1;
}
mydbservice->logger().end(ret);
}
void LumiBasedUpdateAnalyzer::endJob() {
if (m_tagLocks) {
edm::Service<cond::service::OnlineDBOutputService> mydbservice;
mydbservice->releaseLocks();

void LumiBasedUpdateAnalyzer::endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup) {
edm::Service<cond::service::OnlineDBOutputService> mydbservice;
if (mydbservice.isAvailable()) {
mydbservice->logger().logInfo() << "EndLuminosityBlock";
mydbservice->logger().end(m_ret);
}
}

void LumiBasedUpdateAnalyzer::analyze(const edm::Event& evt, const edm::EventSetup& evtSetup) {
std::cout << "LumiBasedUpdateAnalyzer::analyze " << std::endl;
}

DEFINE_FWK_MODULE(LumiBasedUpdateAnalyzer);
7 changes: 5 additions & 2 deletions CondCore/DBOutputService/test/stubs/LumiBasedUpdateAnalyzer.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,15 @@ class LumiBasedUpdateAnalyzer : public edm::EDAnalyzer {
public:
explicit LumiBasedUpdateAnalyzer(const edm::ParameterSet& iConfig);
virtual ~LumiBasedUpdateAnalyzer();
virtual void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup);
virtual void beginJob();
virtual void endJob();
virtual void beginLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& context);
virtual void endLuminosityBlock(const edm::LuminosityBlock& lumiSeg, const edm::EventSetup& iSetup);
virtual void analyze(const edm::Event& evt, const edm::EventSetup& evtSetup);

private:
std::string m_record;
bool m_tagLocks;
int m_ret;
// ----------member data ---------------------------
};
#endif

0 comments on commit b841f21

Please sign in to comment.