mirror of https://gitee.com/bigwinds/arangodb
Fix various things in agency callback handling in coordinator.
This commit is contained in:
parent
e52768c497
commit
fcf9d32ba4
|
@ -124,18 +124,11 @@ bool AgencyCallback::execute(std::shared_ptr<VPackBuilder> newData) {
|
|||
void AgencyCallback::executeByCallbackOrTimeout(double maxTimeout) {
|
||||
// One needs to acquire the mutex of the condition variable
|
||||
// before entering this function!
|
||||
auto compareBuilder = std::make_shared<VPackBuilder>();
|
||||
if (_lastData) {
|
||||
compareBuilder = _lastData;
|
||||
}
|
||||
|
||||
if (!_cv.wait(static_cast<uint64_t>(maxTimeout * 1000000.0))) {
|
||||
if (!_lastData || !_lastData->slice().equals(compareBuilder->slice())) {
|
||||
LOG_TOPIC(DEBUG, Logger::CLUSTER)
|
||||
<< "Waiting done and nothing happended. Refetching to be sure";
|
||||
// mop: watches have not triggered during our sleep...recheck to be sure
|
||||
refetchAndUpdate(false);
|
||||
}
|
||||
LOG_TOPIC(DEBUG, Logger::CLUSTER)
|
||||
<< "Waiting done and nothing happended. Refetching to be sure";
|
||||
// mop: watches have not triggered during our sleep...recheck to be sure
|
||||
refetchAndUpdate(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -839,7 +839,6 @@ int ClusterInfo::createDatabaseCoordinator(std::string const& name,
|
|||
*dbServerResult = TRI_ERROR_CLUSTER_COULD_NOT_CREATE_DATABASE;
|
||||
return true;
|
||||
}
|
||||
loadCurrent(); // update our cache
|
||||
*dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, *errMsg);
|
||||
}
|
||||
return true;
|
||||
|
@ -897,6 +896,7 @@ int ClusterInfo::createDatabaseCoordinator(std::string const& name,
|
|||
}
|
||||
|
||||
if (*dbServerResult >= 0) {
|
||||
loadCurrent(); // update our cache
|
||||
return *dbServerResult;
|
||||
}
|
||||
|
||||
|
@ -1062,7 +1062,6 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
|
|||
}
|
||||
}
|
||||
}
|
||||
loadCurrent();
|
||||
if (tmpHaveError) {
|
||||
*errMsg = "Error in creation of collection:" + tmpMsg;
|
||||
*dbServerResult = TRI_ERROR_CLUSTER_COULD_NOT_CREATE_COLLECTION;
|
||||
|
@ -1122,6 +1121,7 @@ int ClusterInfo::createCollectionCoordinator(std::string const& databaseName,
|
|||
errorMsg = *errMsg;
|
||||
|
||||
if (*dbServerResult >= 0) {
|
||||
loadCurrent();
|
||||
return *dbServerResult;
|
||||
}
|
||||
|
||||
|
@ -1156,24 +1156,8 @@ int ClusterInfo::dropCollectionCoordinator(std::string const& databaseName,
|
|||
auto errMsg = std::make_shared<std::string>();
|
||||
std::function<bool(VPackSlice const& result)> dbServerChanged =
|
||||
[=](VPackSlice const& result) {
|
||||
AgencyComm ac;
|
||||
if (result.isObject() && result.length() == 0) {
|
||||
// ...remove the entire directory for the collection
|
||||
AgencyCommResult res;
|
||||
res = ac.removeValues(
|
||||
"Current/Collections/" + databaseName + "/" + collectionID, true);
|
||||
if (res.successful()) {
|
||||
*dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, *errMsg);
|
||||
return true;
|
||||
}
|
||||
*dbServerResult = setErrormsg(
|
||||
TRI_ERROR_CLUSTER_COULD_NOT_REMOVE_COLLECTION_IN_CURRENT,
|
||||
*errMsg);
|
||||
return true;
|
||||
|
||||
loadCurrent();
|
||||
*dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, *errMsg);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
@ -1215,6 +1199,10 @@ int ClusterInfo::dropCollectionCoordinator(std::string const& databaseName,
|
|||
errorMsg = *errMsg;
|
||||
|
||||
if (*dbServerResult >= 0) {
|
||||
// ...remove the entire directory for the collection
|
||||
ac.removeValues(
|
||||
"Current/Collections/" + databaseName + "/" + collectionID, true);
|
||||
loadCurrent()
|
||||
return *dbServerResult;
|
||||
}
|
||||
|
||||
|
@ -1618,8 +1606,6 @@ int ClusterInfo::ensureIndexCoordinator(
|
|||
}
|
||||
resBuilder->add("isNewlyCreated", VPackValue(true));
|
||||
}
|
||||
loadCurrent();
|
||||
|
||||
*dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, *errMsg);
|
||||
return true;
|
||||
}
|
||||
|
@ -1666,6 +1652,7 @@ int ClusterInfo::ensureIndexCoordinator(
|
|||
resultBuilder = *resBuilder;
|
||||
|
||||
if (*dbServerResult >= 0) {
|
||||
loadCurrent();
|
||||
return *dbServerResult;
|
||||
}
|
||||
|
||||
|
@ -1767,7 +1754,6 @@ int ClusterInfo::dropIndexCoordinator(std::string const& databaseName,
|
|||
}
|
||||
|
||||
if (!found) {
|
||||
loadCurrent();
|
||||
*dbServerResult = setErrormsg(TRI_ERROR_NO_ERROR, *errMsg);
|
||||
}
|
||||
}
|
||||
|
@ -1884,6 +1870,7 @@ int ClusterInfo::dropIndexCoordinator(std::string const& databaseName,
|
|||
errorMsg = *errMsg;
|
||||
|
||||
if (*dbServerResult >= 0) {
|
||||
loadCurrent();
|
||||
return *dbServerResult;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue