Skip to content

Commit 698c84a

Browse files
abhinavdangetichiyoung
authored andcommitted
Address data race in flushVBucket context: lastTransTimePerItem
WARNING: ThreadSanitizer: data race (pid=4590) Write of size 8 at 0x7d540000fe88 by thread T8 (mutexes: write M11599): #0 EventuallyPersistentStore::flushVBucket(unsigned short) /home/abhinav/couchbase/ep-engine/src/ep.cc:3307 (ep.so+0x00000009954f) couchbase#1 Flusher::flushVB() /home/abhinav/couchbase/ep-engine/src/flusher.cc:296 (ep.so+0x0000000ff32f) couchbase#2 Flusher::step(GlobalTask*) /home/abhinav/couchbase/ep-engine/src/flusher.cc:186 (ep.so+0x0000000fd825) couchbase#3 FlusherTask::run() /home/abhinav/couchbase/ep-engine/src/tasks.cc:63 (ep.so+0x00000013bbb2) couchbase#4 ExecutorThread::run() /home/abhinav/couchbase/ep-engine/src/executorthread.cc:112 (ep.so+0x0000000f89b6) couchbase#5 launch_executor_thread(void*) /home/abhinav/couchbase/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000f8555) #6 platform_thread_wrap /home/abhinav/couchbase/platform/src/cb_pthreads.c:23 (libplatform.so.0.1.0+0x000000003d31) Previous write of size 8 at 0x7d540000fe88 by thread T6 (mutexes: write M11602): #0 EventuallyPersistentStore::flushVBucket(unsigned short) /home/abhinav/couchbase/ep-engine/src/ep.cc:3307 (ep.so+0x00000009954f) couchbase#1 Flusher::flushVB() /home/abhinav/couchbase/ep-engine/src/flusher.cc:296 (ep.so+0x0000000ff32f) couchbase#2 Flusher::step(GlobalTask*) /home/abhinav/couchbase/ep-engine/src/flusher.cc:186 (ep.so+0x0000000fd825) couchbase#3 FlusherTask::run() /home/abhinav/couchbase/ep-engine/src/tasks.cc:63 (ep.so+0x00000013bbb2) couchbase#4 ExecutorThread::run() /home/abhinav/couchbase/ep-engine/src/executorthread.cc:112 (ep.so+0x0000000f89b6) couchbase#5 launch_executor_thread(void*) /home/abhinav/couchbase/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000f8555) #6 platform_thread_wrap /home/abhinav/couchbase/platform/src/cb_pthreads.c:23 (libplatform.so.0.1.0+0x000000003d31) Change-Id: Iccf1b0eacba495a8147fe81922361d566cb1d6a0 Reviewed-on: http://review.couchbase.org/55786 Reviewed-by: Sundararaman Sridharan <[email protected]> Tested-by: buildbot <[email protected]> Reviewed-by: Chiyoung Seo <[email protected]>
1 parent 0a5331f commit 698c84a

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/ep.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3304,9 +3304,9 @@ int EventuallyPersistentStore::flushVBucket(uint16_t vbid) {
33043304
hrtime_t end = gethrtime();
33053305
uint64_t trans_time = (end - flush_start) / 1000000;
33063306

3307-
lastTransTimePerItem = (items_flushed == 0) ? 0 :
3308-
static_cast<double>(trans_time) /
3309-
static_cast<double>(items_flushed);
3307+
lastTransTimePerItem.store((items_flushed == 0) ? 0 :
3308+
static_cast<double>(trans_time) /
3309+
static_cast<double>(items_flushed));
33103310
stats.cumulativeFlushTime.fetch_add(ep_current_time()
33113311
- flush_start);
33123312
stats.flusher_todo.store(0);

src/ep.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,7 +712,7 @@ class EventuallyPersistentStore {
712712
}
713713

714714
size_t getTransactionTimePerItem() {
715-
return lastTransTimePerItem;
715+
return lastTransTimePerItem.load();
716716
}
717717

718718
bool isFlushAllScheduled() {
@@ -1029,7 +1029,7 @@ class EventuallyPersistentStore {
10291029
AtomicValue<size_t> replicaRatio;
10301030
} cachedResidentRatio;
10311031
size_t statsSnapshotTaskId;
1032-
size_t lastTransTimePerItem;
1032+
AtomicValue<size_t> lastTransTimePerItem;
10331033
item_eviction_policy_t eviction_policy;
10341034

10351035
Mutex compactionLock;

0 commit comments

Comments
 (0)