Skip to content

Commit c26acb7

Browse files
abhinavdangetichiyoung
authored andcommitted
Address possible data race in VBCBAdaptor
WARNING: ThreadSanitizer: data race (pid=12312) Read of size 2 at 0x7d400000fff8 by main thread (mutexes: write M12542): #0 VBCBAdaptor::getDescription() /home/abhinav/couchbase/ep-engine/src/ep.h:128 (ep.so+0x0000000a7fe1) couchbase#1 ExecutorPool::_stopTaskGroup(unsigned long, task_type_t, bool) /home/abhinav/couchbase/ep-engine/src/executorpool.cc:562 (ep.so+0x0000000f3c21) couchbase#2 ExecutorPool::stopTaskGroup(unsigned long, task_type_t, bool) /home/abhinav/couchbase/ep-engine/src/executorpool.cc:585 (ep.so+0x0000000f3f5e) couchbase#3 ~EventuallyPersistentStore /home/abhinav/couchbase/ep-engine/src/ep.cc:468 (ep.so+0x0000000836c6) couchbase#4 ~EventuallyPersistentEngine /home/abhinav/couchbase/ep-engine/src/ep_engine.cc:6326 (ep.so+0x0000000d4eda) couchbase#5 EvpDestroy(engine_interface*, bool) /home/abhinav/couchbase/ep-engine/src/ep_engine.cc:141 (ep.so+0x0000000b4b8c) #6 mock_destroy(engine_interface*, bool) /home/abhinav/couchbase/memcached/programs/engine_testapp/engine_testapp.cc:98 (engine_testapp+0x0000000ba027) #7 destroy_bucket(engine_interface*, engine_interface_v1*, bool) /home/abhinav/couchbase/memcached/programs/engine_testapp/engine_testapp.cc:995 (engine_testapp+0x0000000b952e) #8 __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287 (libc.so.6+0x000000021ec4) Previous write of size 2 at 0x7d400000fff8 by thread T10: #0 VBCBAdaptor::run() /home/abhinav/couchbase/ep-engine/src/ep.cc:3776 (ep.so+0x00000009d7e3) couchbase#1 ExecutorThread::run() /home/abhinav/couchbase/ep-engine/src/executorthread.cc:112 (ep.so+0x0000000f94d3) couchbase#2 launch_executor_thread(void*) /home/abhinav/couchbase/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000f9055) couchbase#3 platform_thread_wrap /home/abhinav/couchbase/platform/src/cb_pthreads.c:23 (libplatform.so.0.1.0+0x000000003d31) Change-Id: I316fb1a845fbee09f634d39e64057c170fab4795 Reviewed-on: http://review.couchbase.org/55775 Tested-by: abhinav dangeti <abhinav@couchbase.com> Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com>
1 parent b4a6687 commit c26acb7

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/ep.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3773,7 +3773,7 @@ VBCBAdaptor::VBCBAdaptor(EventuallyPersistentStore *s,
37733773

37743774
bool VBCBAdaptor::run(void) {
37753775
if (!vbList.empty()) {
3776-
currentvb = vbList.front();
3776+
currentvb.store(vbList.front());
37773777
RCPtr<VBucket> vb = store->vbMap.getBucket(currentvb);
37783778
if (vb) {
37793779
if (visitor->pauseVisitor()) {

src/ep.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class VBCBAdaptor : public GlobalTask {
125125

126126
std::string getDescription() {
127127
std::stringstream rv;
128-
rv << label << " on vb " << currentvb;
128+
rv << label << " on vb " << currentvb.load();
129129
return rv.str();
130130
}
131131

@@ -137,7 +137,7 @@ class VBCBAdaptor : public GlobalTask {
137137
shared_ptr<VBucketVisitor> visitor;
138138
const char *label;
139139
double sleepTime;
140-
uint16_t currentvb;
140+
AtomicValue<uint16_t> currentvb;
141141

142142
DISALLOW_COPY_AND_ASSIGN(VBCBAdaptor);
143143
};

0 commit comments

Comments
 (0)