From: Alexey Sheplyakov Date: Thu, 3 Mar 2016 12:30:23 +0000 (+0300) Subject: hammer: tools: fix race condition in seq/rand bench (part 1) X-Git-Tag: v0.94.7~22^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F7896%2Fhead;p=ceph.git hammer: tools: fix race condition in seq/rand bench (part 1) src/common/obj_bencher.cc:601: the lock should be taken before calling completion_ret, not after. Also note that if r < 0 the lock will be unlocked twice in a row. As a result rados bench seq fails with assertion in Mutex::Unlock(). Signed-off-by: Piotr Dałek Signed-off-by: Alexey Sheplyakov (cherry picked from commit 0c8faf7c9982c564002771c3a41362a833ace9bb) Conflicts: src/common/obj_bencher.cc src/common/obj_bencher.h Pick only the lock related part to unbreak seq bench. The failure due to the missing (or wrong sized) objects can be easily worked around, and the changes required to fix this problem are way too intrusive for hammer. http://tracker.ceph.com/issues/14873 Related: #14873 --- diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index db4fd8f8c73a..9957eddde098 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -598,13 +598,13 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre index[slot] = data.started; lock.Unlock(); completion_wait(slot); + lock.Lock(); r = completion_ret(slot); if (r < 0) { cerr << "read got " << r << std::endl; lock.Unlock(); goto ERR; } - lock.Lock(); total_latency += data.cur_latency; if (data.cur_latency > data.max_latency) data.max_latency = data.cur_latency; if (data.cur_latency < data.min_latency) data.min_latency = data.cur_latency;