diff --git a/objectstore/BackendRados.cpp b/objectstore/BackendRados.cpp index 8d540957652ab22fcfb61a82e583f4fc95f6be3d..2d848b27edfa33461187ec0410e9b409dce1f663 100644 --- a/objectstore/BackendRados.cpp +++ b/objectstore/BackendRados.cpp @@ -152,6 +152,9 @@ std::string BackendRados::createUniqueClientId() { } BackendRados::ScopedLock* BackendRados::lockExclusive(std::string name) { + // In Rados, locking a non-existing object will create it. This is not our intended + // behavior. So we test for existence beforehand. + if (!exists(name)) throw cta::exception::Errnum(ENOENT, "In BackendRados::lockExclusive(): trying to lock a non-existing object"); std::string client = createUniqueClientId(); struct timeval tv; tv.tv_usec = 0; @@ -169,6 +172,9 @@ BackendRados::ScopedLock* BackendRados::lockExclusive(std::string name) { } BackendRados::ScopedLock* BackendRados::lockShared(std::string name) { + // In Rados, locking a non-existing object will create it. This is not our intended + // behavior. So we test for existence beforehand. + if (!exists(name)) throw cta::exception::Errnum(ENOENT, "In BackendRados::lockShared(): trying to lock a non-existing object"); std::string client = createUniqueClientId(); struct timeval tv; tv.tv_usec = 0;