MB-19277: Set executorThread's waketime to atomic 29/63029/6
authorabhinavdangeti <abhinav@couchbase.com>
Thu, 22 Oct 2015 01:55:28 +0000 (18:55 -0700)
committerChiyoung Seo <chiyoung@couchbase.com>
Sat, 23 Apr 2016 01:13:19 +0000 (01:13 +0000)
commit6387cef83f3d23c659f5934e243705d55ba70aae
treeec2156a7548d5a70c61f542f5d8bec91a650e5f4
parent1d61bf30416aa98b6bd742ac8b104d3782a4063a
MB-19277: Set executorThread's waketime to atomic

This one looks benign - we only perform the dirty read when
calculating the %s:waketime stat which is not used by anyone apart
from end-users.

WARNING: ThreadSanitizer: data race (pid=41666)
  Read of size 8 at 0x7d4400008370 by main thread (mutexes: write M21616):
    #0 ExecutorThread::getWaketime() ep-engine/src/executorthread.h:120 (ep.so+0x0000001cac0e)
    #1 addWorkerStats(char const*, ExecutorThread*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/executorpool.cc:692 (ep.so+0x0000001b6f06)
    #2 ExecutorPool::doWorkerStat(EventuallyPersistentEngine*, void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/executorpool.cc:706 (ep.so+0x0000001b6734)
    #3 EventuallyPersistentEngine::doDispatcherStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:4139 (ep.so+0x00000015223e)
    #4 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:4375 (ep.so+0x000000155336)

  Previous write of size 8 at 0x7d4400008370 by thread T6 (mutexes: write M14985):
    #0 TaskQueue::_fetchNextTask(ExecutorThread&, bool) ep-engine/src/taskqueue.cc:125 (ep.so+0x00000025b3fd)
    #1 TaskQueue::fetchNextTask(ExecutorThread&, bool) ep-engine/src/taskqueue.cc:161 (ep.so+0x00000025bfcf)
    #2 ExecutorPool::_nextTask(ExecutorThread&, unsigned char) ep-engine/src/executorpool.cc:217 (ep.so+0x0000001afc67)
    #3 ExecutorPool::nextTask(ExecutorThread&, unsigned char) ep-engine/src/executorpool.cc:232 (ep.so+0x0000001afe3f)
    #4 ExecutorThread::run() ep-engine/src/executorthread.cc:81 (ep.so+0x0000001e85c9)

Change-Id: I34b12681dd9dfc87c889f301692ca714f04d2a82
Reviewed-on: http://review.couchbase.org/63029
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.cc
src/executorthread.h