From 3a5b1029f8f30bca569b12195329224208855096 Mon Sep 17 00:00:00 2001 From: Alexey Sheplyakov Date: Thu, 3 Mar 2016 15:30:23 +0300 Subject: [PATCH] hammer: tools: fix race condition in seq/rand bench (part 1) MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/common/obj_bencher.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index db4fd8f8c73a8..9957eddde098f 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; -- 2.39.5