MB-19276: Fix data race on ExecutorThread::taskStart 28/63028/6
authorabhinavdangeti <abhinav@couchbase.com>
Tue, 8 Dec 2015 21:48:20 +0000 (13:48 -0800)
committerChiyoung Seo <chiyoung@couchbase.com>
Sat, 23 Apr 2016 01:12:50 +0000 (01:12 +0000)
WARNING: ThreadSanitizer: data race (pid=236996)
  Write of size 8 at 0x7d380000dbd8 by thread T5:
    #0 ExecutorThread::run() ep-engine/src/executorthread.cc:105 (ep.so+0x0000000ee0cc)
    #1 launch_executor_thread(void*) ep-engine/src/executorthread.cc:33 (ep.so+0x0000000edd75)
    #2 platform_thread_wrap(void*) platform/src/cb_pthreads.cc:54 (libplatform.so.0.1.0+0x000000004e7b)

  Previous read of size 8 at 0x7d380000dbd8 by main thread (mutexes: write M266835151185571736):
    #0 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/executorthread.h:108 (ep.so+0x0000000ea8dc)
    #1 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:4363 (ep.so+0x0000000c05dd)
    #2 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:219 (ep.so+0x0000000af40e)
    #3 mock_get_stats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) memcached/programs/engine_testapp/engine_testapp.cc:240 (engine_testapp+0x0000004cc71d)
    #4 test_worker_stats(engine_interface*, engine_interface_v1*) ep-engine/tests/ep_testsuite.cc:9464 (ep_testsuite.so+0x00000003c038)
    #5 execute_test(test, char const*, char const*) memcached/programs/engine_testapp/engine_testapp.cc:1091 (engine_testapp+0x0000004cb315)
    #6 __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 (libc.so.6+0x00000002176c)

Change-Id: If01aba3cf6b3591f19c5bb62119e40998f12c8ff
Reviewed-on: http://review.couchbase.org/63028
Well-Formed: buildbot <build@couchbase.com>
Reviewed-by: Jim Walker <jim@couchbase.com>
Reviewed-by: Will Gardner <will.gardner@couchbase.com>
Tested-by: buildbot <build@couchbase.com>
src/executorthread.h

index 2c42862..0419122 100644 (file)
@@ -27,6 +27,8 @@
 #include <utility>
 #include <vector>
 
+#include <relaxed_atomic.h>
+
 #include "atomic.h"
 #include "common.h"
 #include "mutex.h"
@@ -132,7 +134,7 @@ private:
     AtomicValue<hrtime_t> now;  // record of current time
     hrtime_t waketime; // set to the earliest
 
-    hrtime_t taskStart;
+    Couchbase::RelaxedAtomic<hrtime_t> taskStart;
 
     Mutex currentTaskMutex; // Protects currentTask
     ExTask currentTask;