1
0
Fork 0

Fix deadlock.

This commit is contained in:
Max Neunhoeffer 2019-06-05 13:53:08 +02:00
parent 6c0eb693a1
commit 03ebd5f613
No known key found for this signature in database
GPG Key ID: 89A912AD5E343E1E
1 changed files with 10 additions and 8 deletions

View File

@ -1987,17 +1987,19 @@ Result ClusterInfo::createCollectionsCoordinator(std::string const& databaseName
TRI_ASSERT(agencyCallbacks.size() == infos.size());
for (size_t i = 0; i < infos.size(); ++i) {
if (infos[i].state == ClusterCollectionCreationInfo::INIT) {
bool wokenUp = false;
{
// This one has not responded, wait for it.
CONDITION_LOCKER(locker, agencyCallbacks[i]->_cv);
bool wokenUp = agencyCallbacks[i]->executeByCallbackOrTimeout(interval);
if (wokenUp) {
// We got woken up by waittime, not by callback.
// Let us check if we skipped other callbacks as well
for (; i < infos.size(); ++i) {
if (infos[i].state == ClusterCollectionCreationInfo::INIT) {
agencyCallbacks[i]->refetchAndUpdate(true, false);
}
wokenUp = agencyCallbacks[i]->executeByCallbackOrTimeout(interval);
}
if (wokenUp) {
++i;
// We got woken up by waittime, not by callback.
// Let us check if we skipped other callbacks as well
for (; i < infos.size(); ++i) {
if (infos[i].state == ClusterCollectionCreationInfo::INIT) {
agencyCallbacks[i]->refetchAndUpdate(true, false);
}
}
}