Skip to content

Commit 60bbbee

Browse files
abhinavdangetichiyoung
authored andcommitted
MB-19260: Make cookie atomic to serialize set/get in ConnHandler
WARNING: ThreadSanitizer: data race (pid=20056) Write of size 8 at 0x7d600000f038 by main thread (mutexes: write M1412): #0 ConnHandler::setCookie(void const*) /home/abhinav/couchbase/ep-engine/src/tapconnection.h:344 (ep.so+0x000000042367) #1 EventuallyPersistentEngine::createTapQueue(void const*, std::string&, unsigned int, void const*, unsigned long) /home/abhinav/couchbase/ep-engine/src/ep_engine.cc:2655 (ep.so+0x0000000b86da) #2 EvpGetTapIterator(engine_interface*, void const*, void const*, unsigned long, unsigned int, void const*, unsigned long) /home/abhinav/couchbase/ep-engine/src/ep_engine.cc:1462 (ep.so+0x0000000b46a3) #3 mock_get_tap_iterator(engine_interface*, void const*, void const*, unsigned long, unsigned int, void const*, unsigned long) /home/abhinav/couchbase/memcached/programs/engine_testapp/engine_testapp.cc:467 (engine_testapp+0x0000000bae3e) #4 test_tap_ack_stream(engine_interface*, engine_interface_v1*) /home/abhinav/couchbase/ep-engine/tests/ep_testsuite.cc:7341 (ep_testsuite.so+0x000000050416) #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 8 at 0x7d600000f038 by thread T9 (mutexes: write M1411): #0 ConnHandler::getCookie() const /home/abhinav/couchbase/ep-engine/src/tapconnection.h:340 (ep.so+0x00000004067c) #1 bool TapConnMap::performOp<Item*>(std::string const&, TapOperation<Item*>&, Item*) /home/abhinav/couchbase/ep-engine/src/connmap.h:389 (ep.so+0x00000001fa08) #2 ItemResidentCallback::callback(CacheLookup&) /home/abhinav/couchbase/ep-engine/src/backfill.cc:63 (ep.so+0x00000001d9ca) #3 CouchKVStore::recordDbDump(_db*, _docinfo*, void*) /home/abhinav/couchbase/ep-engine/src/couch-kvstore/couch-kvstore.cc:1654 (ep.so+0x000000180ca0) #4 recordDbDumpC(_db*, _docinfo*, void*) /home/abhinav/couchbase/ep-engine/src/couch-kvstore/couch-kvstore.cc:66 (ep.so+0x00000017fe95) #5 lookup_callback(couchfile_lookup_request*, _sized_buf const*, _sized_buf const*) /home/abhinav/couchbase/couchstore/src/couch_db.cc:767 (libcouchstore.so+0x00000000d7e5) #6 btree_lookup_inner(couchfile_lookup_request*, unsigned long, int, int) /home/abhinav/couchbase/couchstore/src/btree_read.cc:99 (libcouchstore.so+0x00000000b5a2) #7 btree_lookup /home/abhinav/couchbase/couchstore/src/btree_read.cc:131 (libcouchstore.so+0x00000000affc) #8 couchstore_changes_since /home/abhinav/couchbase/couchstore/src/couch_db.cc:812 (libcouchstore.so+0x00000000d5f1) #9 CouchKVStore::scan(ScanContext*) /home/abhinav/couchbase/ep-engine/src/couch-kvstore/couch-kvstore.cc:1264 (ep.so+0x00000017f94e) #10 BackfillDiskLoad::run() /home/abhinav/couchbase/ep-engine/src/backfill.cc:131 (ep.so+0x00000001e449) #11 ExecutorThread::run() /home/abhinav/couchbase/ep-engine/src/executorthread.cc:112 (ep.so+0x0000000f8956) #12 launch_executor_thread(void*) /home/abhinav/couchbase/ep-engine/src/executorthread.cc:33 (ep.so+0x0000000f84f5) #13 platform_thread_wrap /home/abhinav/couchbase/platform/src/cb_pthreads.c:23 (libplatform.so.0.1.0+0x000000003d31) Change-Id: I8a668f17013c95abc9786d853ed2c6462cae5320 Reviewed-on: http://review.couchbase.org/62978 Well-Formed: buildbot <build@couchbase.com> Reviewed-by: Will Gardner <will.gardner@couchbase.com> Tested-by: buildbot <build@couchbase.com>
1 parent 7a47e23 commit 60bbbee

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

src/tapconnection.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ ConnHandler::ConnHandler(EventuallyPersistentEngine& e, const void* c,
153153
stats(engine_.getEpStats()),
154154
supportCheckpointSync_(false),
155155
name(n),
156-
cookie(c),
156+
cookie(const_cast<void*>(c)),
157157
reserved(false),
158158
connToken(gethrtime()),
159159
created(ep_current_time()),

src/tapconnection.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -340,11 +340,11 @@ class ConnHandler : public RCValue {
340340
}
341341

342342
const void *getCookie() const {
343-
return cookie;
343+
return cookie.load();
344344
}
345345

346346
void setCookie(const void *c) {
347-
cookie = c;
347+
cookie.store(const_cast<void*>(c));
348348
}
349349

350350
void setExpiryTime(rel_time_t t) {
@@ -408,7 +408,7 @@ class ConnHandler : public RCValue {
408408
std::string logString;
409409

410410
//! The cookie representing this connection (provided by the memcached code)
411-
const void* cookie;
411+
AtomicValue<void*> cookie;
412412

413413
//! Whether or not the connection is reserved in the memcached layer
414414
AtomicValue<bool> reserved;

0 commit comments

Comments
 (0)