Fix race in updating Vbucket.file{SpaceUsed,Size}

As identified by ThreadSantizer:

    WARNING: ThreadSanitizer: data race (pid=4009)
      Write of size 8 at 0x7d440000c5b0 by thread T6 (mutexes: write M55):
	#0 KVStatsCallback::callback(KVStatsCtx&) /repos/couchbase/server/source/ep-engine/src/ep.cc:933 (ep.so+0x0000000f0a22)
	#1 CouchKVStore::commit2couchstore(Callback<KVStatsCtx>*, unsigned long, unsigned long) /repos/couchbase/server/source/ep-engine/src/couch-kvstore/couch-kvstore.cc:1697 (ep.so+0x0000001aa8c6)
	#2 CouchKVStore::commit(Callback<KVStatsCtx>*, unsigned long, unsigned long) /repos/couchbase/server/source/ep-engine/src/couch-kvstore/couch-kvstore.cc:1040 (ep.so+0x0000001a6483)
	#3 EventuallyPersistentStore::flushVBucket(unsigned short) /repos/couchbase/server/source/ep-engine/src/ep.cc:2909 (ep.so+0x0000000e780b)
	#4 Flusher::flushVB() /repos/couchbase/server/source/ep-engine/src/flusher.cc:283 (ep.so+0x00000013f363)
	#5 Flusher::step(GlobalTask*) /repos/couchbase/server/source/ep-engine/src/flusher.cc:174 (ep.so+0x00000013e9c8)
	#6 FlusherTask::run() /repos/couchbase/server/source/ep-engine/src/tasks.cc:44 (ep.so+0x000000174a85)
	#7 ExecutorThread::run() /repos/couchbase/server/source/ep-engine/src/executorthread.cc:110 (ep.so+0x00000014a0c1)
	#8 launch_executor_thread /repos/couchbase/server/source/ep-engine/src/executorthread.cc:34 (ep.so+0x00000014990a)
	#9 platform_thread_wrap /repos/couchbase/server/source/platform/src/cb_pthreads.c:19 (libplatform.so.0.1.0+0x000000002d8b)
	#10 __tsan_write_range ??:0 (libtsan.so.0+0x00000001b1c9)

      Previous read of size 8 at 0x7d440000c5b0 by main thread (mutexes: write M193510842443017784):
	#0 VBucketCountVisitor::visitBucket(RCPtr<VBucket>&) /repos/couchbase/server/source/ep-engine/src/ep_engine.cc:2889 (ep.so+0x00000010c631)
	#1 VBucketCountAggregator::visitBucket(RCPtr<VBucket>&) /repos/couchbase/server/source/ep-engine/src/ep_engine.cc:2926 (ep.so+0x000000121392)
	#2 EventuallyPersistentStore::visit(VBucketVisitor&) /repos/couchbase/server/source/ep-engine/src/ep.cc:3278 (ep.so+0x0000000e99d9)
	#3 EventuallyPersistentEngine::doEngineStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /repos/couchbase/server/source/ep-engine/src/ep_engine.cc:2955 (ep.so+0x00000010cb46)
	#4 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /repos/couchbase/server/source/ep-engine/src/ep_engine.cc:4344 (ep.so+0x000000113c0f)
	#5 EvpGetStats /repos/couchbase/server/source/ep-engine/src/ep_engine.cc:217 (ep.so+0x000000102b14)
	#6 mock_get_stats /repos/couchbase/server/source/memcached/programs/engine_testapp/engine_testapp.c:195 (exe+0x0000000026de)
	#7 get_int_stat(engine_interface*, engine_interface_v1*, char const*, char const*) /repos/couchbase/server/source/ep-engine/tests/ep_test_apis.cc:799 (ep_testsuite.so+0x0000000832d8)
	#8 wait_for_flusher_to_settle(engine_interface*, engine_interface_v1*) /repos/couchbase/server/source/ep-engine/tests/ep_test_apis.cc:900 (ep_testsuite.so+0x000000083cd4)
	#9 wait_for_persisted_value(engine_interface*, engine_interface_v1*, char const*, char const*, unsigned short) /repos/couchbase/server/source/ep-engine/tests/ep_test_apis.cc:917 (ep_testsuite.so+0x000000083de5)
	#10 test_io_stats /repos/couchbase/server/source/ep-engine/tests/ep_testsuite.cc:6279 (ep_testsuite.so+0x0000000468b3)
	#11 execute_test /repos/couchbase/server/source/memcached/programs/engine_testapp/engine_testapp.c:1055 (exe+0x0000000059fc)
	#12 main /repos/couchbase/server/source/memcached/programs/engine_testapp/engine_testapp.c:1313 (exe+0x000000006606)

Change to AtomicValues to fix this.

Change-Id: Ie7f9a403f809e751ff1802cceb5d2a77a483a586
Reviewed-on: http://review.couchbase.org/43314
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Fix race in Flusher._state

Fix race identified by ThreadSanitizer:

    WARNING: ThreadSanitizer: data race (pid=10664)
      Read of size 4 at 0x7d4400009888 by main thread (mutexes: write M18321):
        #0 Flusher::stateName() const /home/vagrant/couchbase-server/ep-engine/src/flusher.cc:119 (ep.so+0x0000001fc22e)
        #1 EventuallyPersistentEngine::doEngineStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:3025 (ep.so+0x000000180649)
        #2 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:4374 (ep.so+0x00000018d960)
        #3 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:214 (ep.so+0x000000174062)
        #4 mock_get_stats /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:196 (exe+0x0000000a741d)
        #5 get_int_stat(engine_interface*, engine_interface_v1*, char const*, char const*) /home/vagrant/couchbase-server/ep-engine/tests/ep_test_apis.cc:799 (ep_testsuite.so+0x0000000dae46)
        #6 verify_curr_items(engine_interface*, engine_interface_v1*, int, char const*) /home/vagrant/couchbase-server/ep-engine/tests/ep_test_apis.cc:834 (ep_testsuite.so+0x0000000e1d31)
        #7 test_dcp_producer_stream_req_disk(engine_interface*, engine_interface_v1*) /home/vagrant/couchbase-server/ep-engine/tests/ep_testsuite.cc:3589 (ep_testsuite.so+0x000000094c9a)
        #8 execute_test /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1055 (exe+0x0000000a3e83)
        #9 main /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1313 (exe+0x0000000a1d84)

      Previous write of size 4 at 0x7d4400009888 by thread T5:
        #0 Flusher::transition_state(flusher_state) /home/vagrant/couchbase-server/ep-engine/src/flusher.cc:114 (ep.so+0x0000001fb7df)
        #1 Flusher::step(GlobalTask*) /home/vagrant/couchbase-server/ep-engine/src/flusher.cc:167 (ep.so+0x0000001fc9d1)
        #2 FlusherTask::run() /home/vagrant/couchbase-server/ep-engine/src/tasks.cc:44 (ep.so+0x00000027870e)
        #3 ExecutorThread::run() /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:110 (ep.so+0x0000002160ff)
        #4 launch_executor_thread(void*) /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:34 (ep.so+0x00000021560a)
        #5 platform_thread_wrap /home/vagrant/couchbase-server/platform/src/cb_pthreads.c:19 (libplatform.so.0.1.0+0x0000000033f4)

Change-Id: Iaeb60efdc1032de7ba344e04cce454cc1d876d40
Reviewed-on: http://review.couchbase.org/43315
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Fix race in DCP Stream.itemReady

Race identified by ThreadSanitizer:

      Read of size 1 at 0x7d480000b458 by main thread (mutexes: write M18384, write M898, write M18351):
        #0 ActiveStream::addStats(void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/dcp-stream.cc:386 (ep.so+0x0000000ff1a9)
        #1 DcpProducer::addStats(void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/dcp-producer.cc:502 (ep.so+0x0000000efcd3)
        #2 ConnStatBuilder::operator()(SingleThreadedRCPtr<ConnHandler>&) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:3725 (ep.so+0x0000001ba97d)
        #3 ConnStatBuilder std::for_each<std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, ConnStatBuilder>(std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, ConnStatBuilder) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algo.h:4417 (ep.so+0x0000001ba5b5)
        #4 void ConnMap::each_UNLOCKED<ConnStatBuilder>(ConnStatBuilder) /home/vagrant/couchbase-server/ep-engine/src/connmap.h:148 (ep.so+0x0000001ba519)
        #5 void ConnMap::each<ConnStatBuilder>(ConnStatBuilder) /home/vagrant/couchbase-server/ep-engine/src/connmap.h:140 (ep.so+0x0000001b2c4e)
        #6 EventuallyPersistentEngine::doDcpStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:3978 (ep.so+0x00000018928e)
        #7 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:4384 (ep.so+0x00000018dc73)
        #8 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:214 (ep.so+0x000000174062)
        #9 mock_get_stats /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:196 (exe+0x0000000a741d)
        #10 get_int_stat(engine_interface*, engine_interface_v1*, char const*, char const*) /home/vagrant/couchbase-server/ep-engine/tests/ep_test_apis.cc:799 (ep_testsuite.so+0x0000000dae46)
        #11 dcp_stream(engine_interface*, engine_interface_v1*, char const*, void const*, unsigned short, unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, int, int, int, int, int, bool) /home/vagrant/couchbase-server/ep-engine/tests/ep_testsuite.cc:3365 (ep_testsuite.so+0x0000000afc65)
        #12 test_dcp_producer_stream_req_disk(engine_interface*, engine_interface_v1*) /home/vagrant/couchbase-server/ep-engine/tests/ep_testsuite.cc:3596 (ep_testsuite.so+0x000000094ed0)
        #13 execute_test /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1055 (exe+0x0000000a3e83)
        #14 main /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1313 (exe+0x0000000a1d84)

      Previous write of size 1 at 0x7d480000b458 by thread T10 (mutexes: write M18363, write M18357):
        #0 ActiveStream::markDiskSnapshot(unsigned long, unsigned long) /home/vagrant/couchbase-server/ep-engine/src/dcp-stream.cc:202 (ep.so+0x0000000fd0c7)
        #1 DCPBackfill::create() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:138 (ep.so+0x0000000d057c)
        #2 DCPBackfill::run() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:95 (ep.so+0x0000000cfe3b)
        #3 BackfillManager::backfill() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill-manager.cc:171 (ep.so+0x0000000c778d)
        #4 BackfillManagerTask::run() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill-manager.cc:50 (ep.so+0x0000000c745a)
        #5 ExecutorThread::run() /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:110 (ep.so+0x00000021646f)
        #6 launch_executor_thread(void*) /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:34 (ep.so+0x00000021597a)
        #7 platform_thread_wrap /home/vagrant/couchbase-server/platform/src/cb_pthreads.c:19 (libplatform.so.0.1.0+0x0000000033f4)

Change-Id: I02cdf26c697f559a0afde91b377f1462c482349c
Reviewed-on: http://review.couchbase.org/43316
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Fix race in ActiveStream.backfillItems

Race identified by ThreadSanitizer:

  Read of size 8 at 0x7d480000b518 by main thread (mutexes: write M18375, write M898, write M18336):
        #0 void STATWRITER_NAMESPACE::add_casted_stat<unsigned long>(char const*, unsigned long const&, void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/statwriter.h:45 (ep.so+0x0000000aacf9)
        #1 ActiveStream::addStats(void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/dcp-stream.cc:378 (ep.so+0x0000000fee1e)
        #2 DcpProducer::addStats(void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/dcp-producer.cc:502 (ep.so+0x0000000efcd3)
        #3 ConnStatBuilder::operator()(SingleThreadedRCPtr<ConnHandler>&) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:3725 (ep.so+0x0000001ba92d)
        #4 ConnStatBuilder std::for_each<std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, ConnStatBuilder>(std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, ConnStatBuilder) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algo.h:4417 (ep.so+0x0000001ba565)
        #5 void ConnMap::each_UNLOCKED<ConnStatBuilder>(ConnStatBuilder) /home/vagrant/couchbase-server/ep-engine/src/connmap.h:148 (ep.so+0x0000001ba4c9)
        #6 void ConnMap::each<ConnStatBuilder>(ConnStatBuilder) /home/vagrant/couchbase-server/ep-engine/src/connmap.h:140 (ep.so+0x0000001b2bfe)
        #7 EventuallyPersistentEngine::doDcpStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:3978 (ep.so+0x00000018923e)
        #8 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:4384 (ep.so+0x00000018dc23)
        #9 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:214 (ep.so+0x000000174012)
        #10 mock_get_stats /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:196 (exe+0x0000000a741d)
        #11 get_ull_stat(engine_interface*, engine_interface_v1*, char const*, char const*) /home/vagrant/couchbase-server/ep-engine/tests/ep_test_apis.cc:817 (ep_testsuite.so+0x0000000e1aa6)
        #12 dcp_stream(engine_interface*, engine_interface_v1*, char const*, void const*, unsigned short, unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, int, int, int, int, int, bool) /home/vagrant/couchbase-server/ep-engine/tests/ep_testsuite.cc:3370 (ep_testsuite.so+0x0000000afd38)
        #13 test_dcp_producer_stream_req_disk(engine_interface*, engine_interface_v1*) /home/vagrant/couchbase-server/ep-engine/tests/ep_testsuite.cc:3596 (ep_testsuite.so+0x000000094ed0)
        #14 execute_test /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1055 (exe+0x0000000a3e83)
        #15 main /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1313 (exe+0x0000000a1d84)

      Previous write of size 8 at 0x7d480000b518 by thread T10 (mutexes: write M276545986342477096, write M18342):
        #0 ActiveStream::backfillReceived(Item*, backfill_source_t) /home/vagrant/couchbase-server/ep-engine/src/dcp-stream.cc:229 (ep.so+0x0000000fd6ab)
        #1 CacheCallback::callback(CacheLookup&) /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:58 (ep.so+0x0000000cf5cc)
        #2 CouchKVStore::recordDbDump(_db*, _docinfo*, void*) /home/vagrant/couchbase-server/ep-engine/src/couch-kvstore/couch-kvstore.cc:1577 (ep.so+0x0000002f3fe7)
        #3 recordDbDumpC(_db*, _docinfo*, void*) /home/vagrant/couchbase-server/ep-engine/src/couch-kvstore/couch-kvstore.cc:74 (ep.so+0x0000002f2b70)
        #4 lookup_callback(couchfile_lookup_request*, _sized_buf const*, _sized_buf const*) /home/vagrant/couchbase-server/couchstore/src/couch_db.cc:729 (libcouchstore.so+0x000000019e46)
        #5 btree_lookup_inner(couchfile_lookup_request*, unsigned long, int, int) /home/vagrant/couchbase-server/couchstore/src/btree_read.cc:101 (libcouchstore.so+0x0000000132d7)
        #6 btree_lookup_inner(couchfile_lookup_request*, unsigned long, int, int) /home/vagrant/couchbase-server/couchstore/src/btree_read.cc:71 (libcouchstore.so+0x000000012bd3)
        #7 btree_lookup /home/vagrant/couchbase-server/couchstore/src/btree_read.cc:133 (libcouchstore.so+0x00000001236b)
        #8 couchstore_changes_since /home/vagrant/couchbase-server/couchstore/src/couch_db.cc:774 (libcouchstore.so+0x0000000196ca)
        #9 CouchKVStore::scan(ScanContext*) /home/vagrant/couchbase-server/ep-engine/src/couch-kvstore/couch-kvstore.cc:1227 (ep.so+0x0000002f2868)
        #10 DCPBackfill::scan() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:150 (ep.so+0x0000000d08ea)
        #11 DCPBackfill::run() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:97 (ep.so+0x0000000cfeb3)
        #12 BackfillManager::backfill() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill-manager.cc:171 (ep.so+0x0000000c778d)
        #13 BackfillManagerTask::run() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill-manager.cc:50 (ep.so+0x0000000c745a)
        #14 ExecutorThread::run() /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:110 (ep.so+0x00000021641f)
        #15 launch_executor_thread(void*) /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:34 (ep.so+0x00000021592a)
        #16 platform_thread_wrap /home/vagrant/couchbase-server/platform/src/cb_pthreads.c:19 (libplatform.so.0.1.0+0x0000000033f4)

Change-Id: I330979be66ea5113f28846f664af70559379f1ae
Reviewed-on: http://review.couchbase.org/43317
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Fix race in ConnNotifier.task access

Race identified by ThreadSanitizer:

      Read of size 8 at 0x7d08000c1430 by thread T10:
        #0 ConnNotifier::notifyConnections() /home/vagrant/couchbase-server/ep-engine/src/connmap.cc:127 (ep.so+0x0000002537e8)
        #1 ConnNotifierCallback::run() /home/vagrant/couchbase-server/ep-engine/src/connmap.cc:80 (ep.so+0x000000277e8b)
        #2 ExecutorThread::run() /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:110 (ep.so+0x0000002163af)
        #3 launch_executor_thread(void*) /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:34 (ep.so+0x0000002158ba)
        #4 platform_thread_wrap /home/vagrant/couchbase-server/platform/src/cb_pthreads.c:19 (libplatform.so.0.1.0+0x0000000033f4)

      Previous write of size 8 at 0x7d08000c1430 by main thread:
        #0 ConnNotifier::start() /home/vagrant/couchbase-server/ep-engine/src/connmap.cc:99 (ep.so+0x00000025336f)
        #1 ConnMap::initialize(conn_notifier_type) /home/vagrant/couchbase-server/ep-engine/src/connmap.cc:194 (ep.so+0x0000002544a6)
        #2 EventuallyPersistentEngine::initialize(char const*) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:2060 (ep.so+0x000000179b4a)
        #3 EvpInitialize(engine_interface*, char const*) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:135 (ep.so+0x000000173675)
        #4 init_engine /home/vagrant/couchbase-server/memcached/utilities/engine_loader.c:116 (libmcd_util.so.1.0.0+0x000000003fac)
        #5 start_your_engines /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:913 (exe+0x0000000a2fb5)
        #6 execute_test /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1048 (exe+0x0000000a3d29)
        #7 main /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1313 (exe+0x0000000a1d84)

Change-Id: I16cfdff1ea363bbb07a62a92f09f829483276b3d
Reviewed-on: http://review.couchbase.org/43318
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>
Fix race in ActiveStream.bufferedBackfill.bytes

Race identified by ThreadSanitizer:

      Read of size 4 at 0x7d480000b554 by main thread (mutexes: write M18379, write M899, write M18337):
        #0 void STATWRITER_NAMESPACE::add_casted_stat<unsigned int>(char const*, unsigned int const&, void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/statwriter.h:45 (ep.so+0x000000107639)
        #1 ActiveStream::addStats(void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/dcp-stream.cc:388 (ep.so+0x0000000ff272)
        #2 DcpProducer::addStats(void (*)(char const*, unsigned short, char const*, unsigned int, void const*), void const*) /home/vagrant/couchbase-server/ep-engine/src/dcp-producer.cc:502 (ep.so+0x0000000efcd3)
        #3 ConnStatBuilder::operator()(SingleThreadedRCPtr<ConnHandler>&) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:3725 (ep.so+0x0000001ba8bd)
        #4 ConnStatBuilder std::for_each<std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, ConnStatBuilder>(std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, std::_List_iterator<SingleThreadedRCPtr<ConnHandler> >, ConnStatBuilder) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_algo.h:4417 (ep.so+0x0000001ba4f5)
        #5 void ConnMap::each_UNLOCKED<ConnStatBuilder>(ConnStatBuilder) /home/vagrant/couchbase-server/ep-engine/src/connmap.h:148 (ep.so+0x0000001ba459)
        #6 void ConnMap::each<ConnStatBuilder>(ConnStatBuilder) /home/vagrant/couchbase-server/ep-engine/src/connmap.h:140 (ep.so+0x0000001b2b8e)
        #7 EventuallyPersistentEngine::doDcpStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:3978 (ep.so+0x0000001891ce)
        #8 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:4384 (ep.so+0x00000018dbb3)
        #9 EvpGetStats(engine_interface*, void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) /home/vagrant/couchbase-server/ep-engine/src/ep_engine.cc:214 (ep.so+0x000000173fa2)
        #10 mock_get_stats /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:196 (exe+0x0000000a741d)
        #11 get_ull_stat(engine_interface*, engine_interface_v1*, char const*, char const*) /home/vagrant/couchbase-server/ep-engine/tests/ep_test_apis.cc:817 (ep_testsuite.so+0x0000000e1aa6)
        #12 dcp_stream(engine_interface*, engine_interface_v1*, char const*, void const*, unsigned short, unsigned int, unsigned long, unsigned long, unsigned long, unsigned long, unsigned long, int, int, int, int, int, bool) /home/vagrant/couchbase-server/ep-engine/tests/ep_testsuite.cc:3370 (ep_testsuite.so+0x0000000afd38)
        #13 test_dcp_producer_stream_req_disk(engine_interface*, engine_interface_v1*) /home/vagrant/couchbase-server/ep-engine/tests/ep_testsuite.cc:3596 (ep_testsuite.so+0x000000094ed0)
        #14 execute_test /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1055 (exe+0x0000000a3e83)
        #15 main /home/vagrant/couchbase-server/memcached/programs/engine_testapp/engine_testapp.c:1313 (exe+0x0000000a1d84)

      Previous write of size 4 at 0x7d480000b554 by thread T10 (mutexes: write M277108936295898408, write M18343):
        #0 ActiveStream::backfillReceived(Item*, backfill_source_t) /home/vagrant/couchbase-server/ep-engine/src/dcp-stream.cc:216 (ep.so+0x0000000fd3d3)
        #1 CacheCallback::callback(CacheLookup&) /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:58 (ep.so+0x0000000cf5cc)
        #2 CouchKVStore::recordDbDump(_db*, _docinfo*, void*) /home/vagrant/couchbase-server/ep-engine/src/couch-kvstore/couch-kvstore.cc:1577 (ep.so+0x0000002f3f77)
        #3 recordDbDumpC(_db*, _docinfo*, void*) /home/vagrant/couchbase-server/ep-engine/src/couch-kvstore/couch-kvstore.cc:74 (ep.so+0x0000002f2b00)
        #4 lookup_callback(couchfile_lookup_request*, _sized_buf const*, _sized_buf const*) /home/vagrant/couchbase-server/couchstore/src/couch_db.cc:729 (libcouchstore.so+0x000000019e46)
        #5 btree_lookup_inner(couchfile_lookup_request*, unsigned long, int, int) /home/vagrant/couchbase-server/couchstore/src/btree_read.cc:101 (libcouchstore.so+0x0000000132d7)
        #6 btree_lookup_inner(couchfile_lookup_request*, unsigned long, int, int) /home/vagrant/couchbase-server/couchstore/src/btree_read.cc:71 (libcouchstore.so+0x000000012bd3)
        #7 btree_lookup /home/vagrant/couchbase-server/couchstore/src/btree_read.cc:133 (libcouchstore.so+0x00000001236b)
        #8 couchstore_changes_since /home/vagrant/couchbase-server/couchstore/src/couch_db.cc:774 (libcouchstore.so+0x0000000196ca)
        #9 CouchKVStore::scan(ScanContext*) /home/vagrant/couchbase-server/ep-engine/src/couch-kvstore/couch-kvstore.cc:1227 (ep.so+0x0000002f27f8)
        #10 DCPBackfill::scan() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:150 (ep.so+0x0000000d08ea)
        #11 DCPBackfill::run() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill.cc:97 (ep.so+0x0000000cfeb3)
        #12 BackfillManager::backfill() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill-manager.cc:171 (ep.so+0x0000000c778d)
        #13 BackfillManagerTask::run() /home/vagrant/couchbase-server/ep-engine/src/dcp-backfill-manager.cc:50 (ep.so+0x0000000c745a)
        #14 ExecutorThread::run() /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:110 (ep.so+0x0000002163af)
        #15 launch_executor_thread(void*) /home/vagrant/couchbase-server/ep-engine/src/executorthread.cc:34 (ep.so+0x0000002158ba)
        #16 platform_thread_wrap /home/vagrant/couchbase-server/platform/src/cb_pthreads.c:19 (libplatform.so.0.1.0+0x0000000033f4)

Change-Id: Ia80928489df9b57b64b463c67fafee5ba15d2aac
Reviewed-on: http://review.couchbase.org/43319
Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
Tested-by: Chiyoung Seo <chiyoung@couchbase.com>