From a7ea6b60ca87ea5bb874c7dc96b343ea060be434 Mon Sep 17 00:00:00 2001 From: Eric Cano <Eric.Cano@cern.ch> Date: Fri, 17 Nov 2017 12:16:34 +0100 Subject: [PATCH] Added handling for agent being GCed before locking. --- objectstore/GarbageCollector.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/objectstore/GarbageCollector.cpp b/objectstore/GarbageCollector.cpp index 52e88c0229..de01b4dbfb 100644 --- a/objectstore/GarbageCollector.cpp +++ b/objectstore/GarbageCollector.cpp @@ -143,7 +143,17 @@ void GarbageCollector::cleanupDeadAgent(const std::string & address, log::LogCon // We do not need to be defensive about exception here as calling function will // deal with them. Agent agent(address, m_objectStore); - ScopedExclusiveLock agLock(agent); + ScopedExclusiveLock agLock; + try { + // The agent could be gone while we try to lock it. + agLock.lock(agent); + } catch (Backend::NoSuchObject & ex) { + log::ScopedParamContainer params(lc); + params.add("agentAddress", agent.getAddressIfSet()) + .add("gcAgentAddress", m_ourAgentReference.getAgentAddress()); + lc.log(log::INFO, "In GarbageCollector::cleanupDeadAgent(): agent already deleted when trying to lock it. Skipping it."); + return; + } agent.fetch(); log::ScopedParamContainer params(lc); params.add("agentAddress", agent.getAddressIfSet()) -- GitLab