8000 Bug fix 3.4: verify communication thread has fully stopped in ClusterComm by matthewvon · Pull Request #7232 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

Bug fix 3.4: verify communication thread has fully stopped in ClusterComm #7232 8000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion arangod/Cluster/ClusterComm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ void ClusterComm::startBackgroundThreads() {
for(unsigned loop=0; loop<(TRI_numberProcessors()/8+1); ++loop) {
ClusterCommThread * thread = new ClusterCommThread();

if (thread->start()) {
if (thread->start(&_activeThreadsCondition)) {
_backgroundThreads.push_back(thread);
} else {
LOG_TOPIC(FATAL, Logger::CLUSTER)
Expand All @@ -343,12 +343,24 @@ void ClusterComm::startBackgroundThreads() {
}

void ClusterComm::stopBackgroundThreads() {
// pass 1: tell all background threads to stop
for (ClusterCommThread * thread: _backgroundThreads) {
thread->beginShutdown();
} // for

// pass 2: verify each thread is stopped, wait if necessary
CONDITION_LOCKER(locker, _activeThreadsCondition);
for (ClusterCommThread * thread: _backgroundThreads) {
// wait until all communications on the thread actual complete
while(thread->isRunning()) {
_activeThreadsCondition.wait(10000);
} // while

delete thread;
}

_backgroundThreads.clear();

}


Expand Down
1 change: 1 addition & 0 deletions arangod/Cluster/ClusterComm.h
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,7 @@ class ClusterComm {

std::atomic_uint _roundRobin;
std::vector<ClusterCommThread*> _backgroundThreads;
arangodb::basics::ConditionVariable _activeThreadsCondition;

std::shared_ptr<communicator::Communicator> communicator();

Expand Down
0