mirror of https://gitee.com/bigwinds/arangodb
Rework dispatchedPlanVersion...fix races
This commit is contained in:
parent
3899ee7588
commit
a889cf5710
|
@ -126,7 +126,7 @@ void HeartbeatThread::runDBServer() {
|
||||||
if (version > _currentPlanVersion) {
|
if (version > _currentPlanVersion) {
|
||||||
_currentPlanVersion = version;
|
_currentPlanVersion = version;
|
||||||
|
|
||||||
mustChangePlan = _dispatchedVersion == 0 && _lastSuccessfulVersion < _currentPlanVersion;
|
mustChangePlan = _lastSuccessfulVersion < _currentPlanVersion;
|
||||||
versionToChange = _currentPlanVersion;
|
versionToChange = _currentPlanVersion;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -602,16 +602,23 @@ bool HeartbeatThread::handlePlanChangeDBServer(uint64_t currentPlanVersion) {
|
||||||
|
|
||||||
// schedule a job for the change
|
// schedule a job for the change
|
||||||
std::unique_ptr<arangodb::rest::Job> job(new ServerJob(this));
|
std::unique_ptr<arangodb::rest::Job> job(new ServerJob(this));
|
||||||
|
|
||||||
auto dispatcher = DispatcherFeature::DISPATCHER;
|
auto dispatcher = DispatcherFeature::DISPATCHER;
|
||||||
|
{
|
||||||
MUTEX_LOCKER(mutexLocker, _statusLock);
|
MUTEX_LOCKER(mutexLocker, _statusLock);
|
||||||
TRI_ASSERT(_dispatchedVersion == 0);
|
// mop: only dispatch one at a time
|
||||||
if (dispatcher->addJob(job) == TRI_ERROR_NO_ERROR) {
|
if (_dispatchedVersion > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
_dispatchedVersion = currentPlanVersion;
|
_dispatchedVersion = currentPlanVersion;
|
||||||
|
}
|
||||||
|
if (dispatcher->addJob(job) == TRI_ERROR_NO_ERROR) {
|
||||||
LOG(TRACE) << "scheduled plan update handler";
|
LOG(TRACE) << "scheduled plan update handler";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
MUTEX_LOCKER(mutexLocker, _statusLock);
|
||||||
|
_dispatchedVersion = 0;
|
||||||
|
|
||||||
|
|
||||||
LOG(ERR) << "could not schedule plan update handler";
|
LOG(ERR) << "could not schedule plan update handler";
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue