Skip to content

Commit 0d3c7d5

Browse files
Address data-race seen with executor pool's instance
If there are open taskables, fail executor pool's shutdown. 10:34:37 WARNING: ThreadSanitizer: data race (pid=16877) 10:34:37 Read of size 8 at 0x7d4c0001bfd8 by thread T3 (mutexes: write M1730): 10:34:37 #0 ExecutorPool::shutdown() /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:736 (fdb_functional_test+0x00000051d75b) 10:34:37 #1 FdbEngine::destroyInstance() /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:2015 (fdb_functional_test+0x000000547a35) 10:34:37 #2 fdb_shutdown /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:1900 (fdb_functional_test+0x0000005479af) 10:34:37 #3 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2036 (fdb_functional_test+0x0000004d5a1e) 10:34:37 10:34:37 Previous write of size 8 at 0x7d4c0001bfd8 by thread T4 (mutexes: write M64224): 10:34:37 #0 std::_Rb_tree<void*, void*, std::_Identity<void*>, std::less<void*>, std::allocator<void*> >::_M_erase_aux(std::_Rb_tree_const_iterator<void*>, std::_Rb_tree_const_iterator<void*>) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_tree.h:909 (fdb_functional_test+0x0000005231b9) 10:34:37 #1 ExecutorPool::_unregisterTaskable(Taskable&, bool) /usr/bin/../lib/gcc/x86_64-linux-gnu/4.9/../../../../include/c++/4.9/bits/stl_set.h:621 (fdb_functional_test+0x00000051d899) 10:34:37 #2 ExecutorPool::unregisterTaskable(Taskable&, bool) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/executorpool.cc:662 (fdb_functional_test+0x000000522ec4) 10:34:37 #3 FileMgr::freeFunc(FileMgr*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/filemgr.cc:1745 (fdb_functional_test+0x00000052b404) 10:34:37 #4 FileMgr::close(FileMgr*, bool, char const*, ErrLogCallback*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/filemgr.cc:1667 (fdb_functional_test+0x00000052d1b3) 10:34:37 #5 FdbEngine::closeKVHandle(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:5058 (fdb_functional_test+0x00000054124b) 10:34:37 #6 FdbEngine::closeRootHandle(FdbKvsHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:5029 (fdb_functional_test+0x000000549c98) 10:34:37 #7 FdbEngine::closeFile(FdbFileHandle*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:4987 (fdb_functional_test+0x0000005455e9) 10:34:37 #8 fdb_close /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/src/forestdb.cc:1769 (fdb_functional_test+0x000000545503) 10:34:37 #9 multi_thread_client_shutdown(void*) /home/couchbase/jenkins/workspace/forestdb-thread_sanitizer-master/forestdb/tests/functional/fdb_functional_test.cc:2033 (fdb_functional_test+0x0000004d59c7) Change-Id: I3758ed5955c1e70e1600eecde5caad8cf31fd944 Reviewed-on: http://review.couchbase.org/67862 Reviewed-by: Sundararaman Sridharan <[email protected]> Reviewed-by: Chiyoung Seo <[email protected]> Tested-by: buildbot <[email protected]>
1 parent 5e3a952 commit 0d3c7d5

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/executorpool.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,18 @@ ExecutorPool *ExecutorPool::get(void) {
161161
return tmp;
162162
}
163163

164-
void ExecutorPool::shutdown(void) {
164+
bool ExecutorPool::shutdown(void) {
165165
LockHolder lh(initGuard);
166166
auto* tmp = instance.load();
167167
if (tmp != nullptr) {
168-
for (auto &taskable : tmp->taskOwners) {
169-
tmp->_unregisterTaskable(*reinterpret_cast<Taskable *>(taskable),
170-
true);
168+
if (tmp->taskOwners.size() != 0) {
169+
// Open taskables
170+
return false;
171171
}
172172
delete tmp;
173173
instance = nullptr;
174174
}
175+
return true;
175176
}
176177

177178
ExecutorPool::ExecutorPool(size_t maxThreads, size_t nTaskSets,

src/executorpool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ class ExecutorPool {
117117

118118
static ExecutorPool *get(void);
119119

120-
static void shutdown(void);
120+
static bool shutdown(void);
121121

122122
protected:
123123

src/forestdb.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,10 @@ fdb_status FdbEngine::destroyInstance() {
20222022
BgFlusher::destroyBgFlusher();
20232023
fdb_status ret = FileMgr::shutdown();
20242024
if (ret == FDB_RESULT_SUCCESS) {
2025-
ExecutorPool::shutdown();
2025+
if (!ExecutorPool::shutdown()) {
2026+
// Open taskables
2027+
return FDB_RESULT_FILE_IS_BUSY;
2028+
}
20262029
// Shutdown HBtrie's memory pool
20272030
HBTrie::shutdownMemoryPool();
20282031
delete tmp;

0 commit comments

Comments
 (0)