1
0
Fork 0

Merge branch 'devel' of https://github.com/arangodb/arangodb into devel

This commit is contained in:
jsteemann 2017-01-30 15:32:41 +01:00
commit 3b83470ce5
3 changed files with 24 additions and 34 deletions

View File

@ -75,7 +75,7 @@ HeartbeatThread::HeartbeatThread(AgencyCallbackRegistry* agencyCallbackRegistry,
_ioService(ioService),
_backgroundJobsPosted(0),
_backgroundJobsLaunched(0),
_backgroundJobRunning(false),
_backgroundJobScheduledOrRunning(false),
_launchAnotherBackgroundJob(false) {
}
@ -106,35 +106,26 @@ void HeartbeatThread::run() {
// jobs in JS:
auto self = shared_from_this();
_backgroundJob = [self, this]() {
{
MUTEX_LOCKER(mutexLocker, *_statusLock);
_backgroundJobRunning = true;
_launchAnotherBackgroundJob = false;
}
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "sync callback started "
<< ++_backgroundJobsLaunched;
uint64_t jobNr = ++_backgroundJobsLaunched;
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "sync callback started " << jobNr;
{
DBServerAgencySync job(this);
job.work();
}
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "sync callback ended "
<< _backgroundJobsLaunched.load();
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "sync callback ended " << jobNr;
bool startAnother = false;
{
MUTEX_LOCKER(mutexLocker, *_statusLock);
_backgroundJobRunning = false;
if (_launchAnotherBackgroundJob) {
startAnother = true;
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "dispatching sync tail "
<< ++_backgroundJobsPosted;
_launchAnotherBackgroundJob = false;
_ioService->post(_backgroundJob);
} else {
_backgroundJobScheduledOrRunning = false;
_launchAnotherBackgroundJob = false;
}
}
if (startAnother) {
LOG_TOPIC(DEBUG, Logger::HEARTBEAT) << "dispatching sync tail "
<< ++_backgroundJobsPosted;
_ioService->post(_backgroundJob);
}
};
runDBServer();
}
@ -253,7 +244,7 @@ void HeartbeatThread::runDBServer() {
agentPool.get("size").getUInt() > 1) {
_agency.updateEndpoints(agentPool);
} else {
LOG(DEBUG) << "Cannot find an agency persisted in RAFT 8|";
LOG(TRACE) << "Cannot find an agency persisted in RAFT 8|";
}
VPackSlice shutdownSlice =
@ -349,15 +340,13 @@ void HeartbeatThread::runDBServer() {
_agencyCallbackRegistry->unregisterCallback(planAgencyCallback);
int count = 0;
while (++count < 3000) {
bool isInPlanChange;
{
MUTEX_LOCKER(mutexLocker, *_statusLock);
isInPlanChange = _backgroundJobRunning;
if (!_backgroundJobScheduledOrRunning) {
break;
}
}
if (!isInPlanChange) {
break;
}
usleep(1000);
usleep(100000);
}
LOG_TOPIC(TRACE, Logger::HEARTBEAT)
<< "stopped heartbeat thread (DBServer version)";
@ -424,7 +413,7 @@ void HeartbeatThread::runCoordinator() {
agentPool.get("size").getUInt() > 1) {
_agency.updateEndpoints(agentPool);
} else {
LOG(DEBUG) << "Cannot find an agency persisted in RAFT 8|";
LOG(TRACE) << "Cannot find an agency persisted in RAFT 8|";
}
VPackSlice shutdownSlice = result.slice()[0].get(
@ -766,7 +755,7 @@ void HeartbeatThread::syncDBServerStatusQuo() {
ci->invalidateCurrent();
}
if (_backgroundJobRunning) {
if (_backgroundJobScheduledOrRunning) {
_launchAnotherBackgroundJob = true;
return;
}

View File

@ -238,12 +238,13 @@ class HeartbeatThread : public Thread,
std::atomic<uint64_t> _backgroundJobsLaunched;
//////////////////////////////////////////////////////////////////////////////
/// @brief flag indicates whether or not a background job is running, this
/// and the next one about having to start another background job when
/// the current one is finished are protected by the statusLock.
/// @brief flag indicates whether or not a background job is either
/// scheduled with boost::asio or is already running, this and the
/// next one about having to start another background job when the
/// current one is finished are protected by the statusLock.
//////////////////////////////////////////////////////////////////////////////
bool _backgroundJobRunning;
bool _backgroundJobScheduledOrRunning;
//////////////////////////////////////////////////////////////////////////////
/// @brief flag indicates whether or not a new background job needs

View File

@ -1293,7 +1293,7 @@ function shutdownInstance (instanceInfo, options) {
analyzeServerCrash(arangod, options, 'instance Shutdown - ' + arangod.exitStatus.signal);
}
} else {
print('Server shutdown: Success.');
print('Server shutdown: Success: pid', arangod.pid);
return false;
}
});