]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
hammer: tools: fix race condition in seq/rand bench (part 1) 7896/head
authorAlexey Sheplyakov <asheplyakov@mirantis.com>
Thu, 3 Mar 2016 12:30:23 +0000 (15:30 +0300)
committerAlexey Sheplyakov <asheplyakov@mirantis.com>
Thu, 3 Mar 2016 12:32:15 +0000 (15:32 +0300)
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 <piotr.dalek@ts.fujitsu.com>
Signed-off-by: Alexey Sheplyakov <asheplyakov@mirantis.com>
(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

index db4fd8f8c73a86ea23817e3faa770d76a7c23805..9957eddde098fc949dc62d594afab0bc0dd0e20f 100644 (file)
@@ -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;