MB-19259: Fix data race on DcpConsumer::backoffs 77/62977/8
authorDave Rigby <daver@couchbase.com>
Thu, 8 Oct 2015 13:55:09 +0000 (13:55 +0000)
committerChiyoung Seo <chiyoung@couchbase.com>
Sat, 23 Apr 2016 01:09:45 +0000 (01:09 +0000)
commit7a47e23cfbe552dba767f76420ca9bfda96d0fde
treeb2635607e191d0074c60447529702b09131be9e3
parent47e799ec1904d17a0bcd57d26db12dd55b9cbfdd
MB-19259: Fix data race on DcpConsumer::backoffs

This member is read by stats processing concurrently with DcpConsumer
updating it. Change to RelaxedAtomic<>

As reported by ThreadSanitizer:

WARNING: ThreadSanitizer: data race (pid=24629)
  Read of size 4 at 0x7d5000016b9c by main thread (mutexes: write M27034, write M2479):
    #0 void ConnHandler::addStat<unsigned int>(), void const*) ep-engine/src/tapconnection.h:291:18 (ep.so+0x00000004e993)
    #1 DcpConsumer::addStats(), void const*) ep-engine/src/dcp/consumer.cc:731:5 (ep.so+0x00000005a2c3)
    ...

  Previous write of size 4 at 0x7d5000016b9c by thread T10:
    #0 DcpConsumer::processBufferedItems() ep-engine/src/dcp/consumer.cc:755:17 (ep.so+0x0000000539c3)
    #1 Processer::run() ep-engine/src/dcp/consumer.cc:57:13 (ep.so+0x00000005376b)
    #2 ExecutorThread::run() ep-engine/src/executorthread.cc:115:26 (ep.so+0x0000000e944e)
    ...

Change-Id: Iabddcc06213fbb80815d4b464c459adb922a0eff
Reviewed-on: http://review.couchbase.org/62977
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/dcp-consumer.h