Commit fc1ddbe0 authored by Eric Cano's avatar Eric Cano
Browse files

Simplified reads in rados backend.

We do not do a stat before reading. Instead we ask for an arbitrarily big read, and find out
the size of the data while reading. This avoids a race condition in lockfree reads where we failed
to get the full object if it got re-written to a bigger size between stat an read.
parent 440246b7
......@@ -66,3 +66,7 @@ void Errnum::throwOnNegative(const int ret, const std::string &context) {
void Errnum::throwOnMinusOne(const int ret, const std::string &context) {
if (-1 == ret) throw Errnum(context);
}
void Errnum::throwOnNegativeErrnoIfNegative(const int ret, const std::string& context) {
if (ret < 0) throw Errnum(-ret, context);
}
......@@ -35,6 +35,7 @@ namespace exception {
static void throwOnNull(const void *const f, const std::string &context = "");
static void throwOnNegative(const int ret, const std::string &context = "");
static void throwOnMinusOne(const int ret, const std::string &context = "");
static void throwOnNegativeErrnoIfNegative(const int ret, const std::string &context = "");
protected:
void ErrnumConstructorBottomHalf(const std::string & what);
int m_errnum;
......
......@@ -79,16 +79,11 @@ void BackendRados::atomicOverwrite(std::string name, std::string content) {
std::string BackendRados::read(std::string name) {
std::string ret;
uint64_t size;
time_t time;
cta::exception::Errnum::throwOnReturnedErrno(-m_radosCtx.stat(name, &size, &time),
std::string("In ObjectStoreRados::read, failed to stat: ")
+ name);
librados::bufferlist bl;
cta::exception::Errnum::throwOnNegative(m_radosCtx.read(name, bl, size, 0),
cta::exception::Errnum::throwOnNegativeErrnoIfNegative(m_radosCtx.read(name, bl, std::numeric_limits<int32_t>::max(), 0),
std::string("In ObjectStoreRados::read, failed to read: ")
+ name);
bl.copy(0, size, ret);
bl.copy(0, bl.length(), ret);
return ret;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment