Skip to content

Commit 3b8a7be

Browse files
abhinavdangetichiyoung
authored andcommitted
MB-16500 [BP]: Address possible data race in ConnHandler: lastWalkTime
WARNING: ThreadSanitizer: data race (pid=26185) Write of size 4 at 0x7d4c0000a154 by main thread: #0 ConnHandler::setLastWalkTime() /home/abhinav/couchbase/ep-engine/src/tapconnection.h:356 (ep.so+0x000000065641) couchbase#1 EvpDcpStep(engine_interface*, void const*, dcp_message_producers*) /home/abhinav/couchbase/ep-engine/src/ep_engine.cc:1478 (ep.so+0x0000000b4d5b) couchbase#2 mock_dcp_step(engine_interface*, void const*, dcp_message_producers*) /home/abhinav/couchbase/memcached/programs/engine_testapp/engine_testapp.cc:476 (engine_testapp+0x0000000baf95) couchbase#3 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, bool, bool, unsigned char, bool, unsigned long*, bool) /home/abhinav/couchbase/ep-engine/tests/ep_testsuite.cc:4164 (ep_testsuite.so+0x0000000990df) couchbase#4 test_dcp_producer_stream_req_dgm(engine_interface*, engine_interface_v1*) /home/abhinav/couchbase/ep-engine/tests/ep_testsuite.cc:4564 (ep_testsuite.so+0x000000077634) couchbase#5 execute_test(test, char const*, char const*) /home/abhinav/couchbase/memcached/programs/engine_testapp/engine_testapp.cc:1090 (engine_testapp+0x0000000b946c) #6 __libc_start_main /build/buildd/eglibc-2.19/csu/libc-start.c:287 (libc.so.6+0x000000021ec4) Previous read of size 4 at 0x7d4c0000a154 by thread T10 (mutexes: write M1367): #0 ConnHandler::getLastWalkTime() /home/abhinav/couchbase/ep-engine/src/tapconnection.h:360 (ep.so+0x000000049cbe) couchbase#1 ConnManager::run() /home/abhinav/couchbase/ep-engine/src/connmap.cc:150 (ep.so+0x00000005031e) couchbase#2 ExecutorThread::run() /home/abhinav/couchbase/ep-engine/src/executorthread.cc:112 (ep.so+0x0000000f8746) couchbase#3 launch_executor_thread(void*) /home/abhinav/couchbase/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000f82e5) couchbase#4 platform_thread_wrap /home/abhinav/couchbase/platform/src/cb_pthreads.c:23 (libplatform.so.0.1.0+0x000000003d31) Change-Id: I2c5024afde6cb749aad901572bfd68734f6d7d5d Reviewed-on: http://review.couchbase.org/55780 Tested-by: buildbot <build@couchbase.com> Reviewed-by: Chiyoung Seo <chiyoung@couchbase.com> Reviewed-on: http://review.couchbase.org/56062
1 parent 495e00a commit 3b8a7be

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/tapconnection.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ class ConnHandler : public RCValue {
353353
}
354354

355355
void setLastWalkTime() {
356-
lastWalkTime = ep_current_time();
356+
lastWalkTime.store(ep_current_time());
357357
}
358358

359359
rel_time_t getLastWalkTime() {
360-
return lastWalkTime;
360+
return lastWalkTime.load();
361361
}
362362

363363
void setConnected(bool s) {
@@ -417,7 +417,7 @@ class ConnHandler : public RCValue {
417417
rel_time_t created;
418418

419419
//! The last time this connection's step function was called
420-
rel_time_t lastWalkTime;
420+
AtomicValue<rel_time_t> lastWalkTime;
421421

422422
//! Should we disconnect as soon as possible?
423423
bool disconnect;

0 commit comments

Comments
 (0)