Skip to content

Commit 47e799e

Browse files
abhinavdangetichiyoung
authored andcommitted
MB-19258: Address data race with replicationThrottle parameters
The detected usage is just in stats, however there is an indirect usage of this variable (persistenceQueueSmallEnough, via stats.replicationThrottleWriteQueueCap) which /might/ result in an incorrect queue size being used. WARNING: ThreadSanitizer: data race (pid=31345) Read of size 8 at 0x7d08000066c0 by thread T12: #0 ReplicationThrottle::adjustWriteQueueCap(unsigned long) ep-engine/src/replicationthrottle.cc:49 (ep.so+0x000000114c7f) #1 EventuallyPersistentEngine::doEngineStats(void const*, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:3100 (ep.so+0x0000000bb424) #2 EventuallyPersistentEngine::getStats(void const*, char const*, int, void (*)(char const*, unsigned short, char const*, unsigned int, void const*)) ep-engine/src/ep_engine.cc:4597 (ep.so+0x0000000c54d5) #3 EventuallyPersistentStore::snapshotStats() ep-engine/src/ep.cc:1744 (ep.so+0x000000090f2e) #4 StatSnap::run() ep-engine/src/tasks.cc:100 (ep.so+0x000000136dd6) #5 ExecutorThread::run() ep-engine/src/executorthread.cc:115 (ep.so+0x0000000f6966) #6 launch_executor_thread(void*) ep-engine/src/executorthread.cc:33 (ep.so+0x0000000f6515) #7 platform_thread_wrap(void*) platform/src/cb_pthreads.cc:54 (libplatform.so.0.1.0+0x00000000551b) 12:23:35 Previous write of size 8 at 0x7d08000066c0 by main thread (mutexes: write M2287262534014660504): #0 EPStoreValueChangeListener::sizeValueChanged(std::string const&, unsigned long) ep-engine/src/replicationthrottle.h:42 (ep.so+0x0000000b35ee) #1 Configuration::setParameter(std::string const&, long) ep-engine/src/configuration.cc:225 (ep.so+0x000000197ac5) #2 Configuration::setReplicationThrottleQueueCap(long const&) build/ep-engine/src/generated_configuration.cc:459 (ep.so+0x0000001a6fa8) #3 setTapParam(EventuallyPersistentEngine*, char const*, char const*, std::string&) ep-engine/src/ep_engine.cc:323 (ep.so+0x0000000d7f3f) #4 EvpUnknownCommand(engine_interface*, void const*, protocol_binary_request_header*, bool (*)(void const*, unsigned short, void const*, unsigned char, void const*, unsigned int, unsigned char, unsigned short, unsigned long, void const*)) ep-engine/src/ep_engine.cc:1365 (ep.so+0x0000000b4f68) #5 mock_unknown_command(engine_interface*, void const*, protocol_binary_request_header*, bool (*)(void const*, unsigned short, void const*, unsigned char, void const*, unsigned int, unsigned char, unsigned short, unsigned long, void const*)) memcached/programs/engine_testapp/engine_testapp.cc:382 (engine_testapp+0x0000004ce149) #6 set_param(engine_interface*, engine_interface_v1*, protocol_binary_engine_param_t, char const*, char const*) ep-engine/tests/ep_test_apis.cc:597 (ep_testsuite_dcp.so+0x000000038e17) #7 test_consumer_backoff_stat(engine_interface*, engine_interface_v1*) ep-engine/tests/ep_testsuite_dcp.cc:2184 (ep_testsuite_dcp.so+0x000000017411) #8 execute_test(test, char const*, char const*) memcached/programs/engine_testapp/engine_testapp.cc:1131 (engine_testapp+0x0000004cc600) #9 __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226 (libc.so.6+0x00000002176c) Change-Id: Ie4ff039603f2ddfc5b44d5d7f217544307655d31 Reviewed-on: http://review.couchbase.org/62976 Well-Formed: buildbot <[email protected]> Reviewed-by: Will Gardner <[email protected]> Tested-by: buildbot <[email protected]>
1 parent aec8019 commit 47e799e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/tapthrottle.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020

2121
#include "config.h"
2222

23+
#include <relaxed_atomic.h>
24+
2325
#include "common.h"
2426
#include "stats.h"
2527

@@ -48,8 +50,8 @@ class TapThrottle {
4850
bool persistenceQueueSmallEnough() const;
4951
bool hasSomeMemory() const;
5052

51-
ssize_t queueCap;
52-
size_t capPercent;
53+
Couchbase::RelaxedAtomic<ssize_t> queueCap;
54+
Couchbase::RelaxedAtomic<size_t> capPercent;
5355
EPStats &stats;
5456
};
5557

0 commit comments

Comments
 (0)