1
0
Fork 0

fixed shutdown issues

This commit is contained in:
jsteemann 2017-06-08 12:30:43 +02:00
parent 7250ba29ee
commit bf209397cd
6 changed files with 32 additions and 19 deletions

View File

@ -28,6 +28,7 @@
#include <velocypack/Iterator.h>
#include <velocypack/velocypack-aliases.h>
#include "ApplicationFeatures/ApplicationServer.h"
#include "Aql/Function.h"
#include "Aql/Query.h"
#include "Basics/Exceptions.h"
@ -1758,9 +1759,10 @@ AqlValue Functions::Sleep(arangodb::aql::Query* query,
if (query->killed()) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_QUERY_KILLED);
} else if (application_features::ApplicationServer::isStopping()) {
THROW_ARANGO_EXCEPTION(TRI_ERROR_SHUTTING_DOWN);
}
}
return AqlValue(arangodb::basics::VelocyPackHelper::NullValue());
}

View File

@ -23,7 +23,6 @@
#include "Query.h"
#include "ApplicationFeatures/ApplicationServer.h"
#include "Aql/AqlItemBlock.h"
#include "Aql/AqlTransaction.h"
#include "Aql/ExecutionBlock.h"
@ -43,7 +42,6 @@
#include "Cluster/ServerState.h"
#include "Logger/Logger.h"
#include "RestServer/AqlFeature.h"
#include "RestServer/QueryRegistryFeature.h"
#include "StorageEngine/TransactionState.h"
#include "Transaction/Methods.h"
#include "Transaction/StandaloneContext.h"
@ -90,7 +88,6 @@ Query::Query(bool contextOwnedByExterior, TRI_vocbase_t* vocbase,
_trx(nullptr),
_warnings(),
_startTime(TRI_microtime()),
_queryRegistry(application_features::ApplicationServer::getFeature<arangodb::QueryRegistryFeature>("QueryRegistry")),
_part(part),
_contextOwnedByExterior(contextOwnedByExterior),
_killed(false),
@ -170,7 +167,6 @@ Query::Query(bool contextOwnedByExterior, TRI_vocbase_t* vocbase,
_trx(nullptr),
_warnings(),
_startTime(TRI_microtime()),
_queryRegistry(application_features::ApplicationServer::getFeature<arangodb::QueryRegistryFeature>("QueryRegistry")),
_part(part),
_contextOwnedByExterior(contextOwnedByExterior),
_killed(false),

View File

@ -55,8 +55,6 @@ namespace velocypack {
class Builder;
}
class QueryRegistryFeature;
namespace aql {
struct AstNode;
@ -342,8 +340,6 @@ class Query {
/// @brief query start time
double _startTime;
QueryRegistryFeature const* _queryRegistry;
/// @brief the query part
QueryPart const _part;

View File

@ -118,8 +118,7 @@ Query* QueryRegistry::open(TRI_vocbase_t* vocbase, QueryId id) {
auto m = _queries.find(vocbase->name());
if (m == _queries.end()) {
m = _queries.emplace(vocbase->name(),
std::unordered_map<QueryId, QueryInfo*>()).first;
return nullptr;
}
auto q = m->second.find(id);
if (q == m->second.end()) {
@ -290,6 +289,10 @@ void QueryRegistry::destroyAll() {
}
}
for (auto& p : allQueries) {
try {
destroy(p.first, p.second, TRI_ERROR_SHUTTING_DOWN);
} catch (...) {
// ignore any errors here
}
}
}

View File

@ -30,7 +30,6 @@
#include "RestServer/QueryRegistryFeature.h"
#include "RestServer/TraverserEngineRegistryFeature.h"
using namespace arangodb;
using namespace arangodb::application_features;
@ -68,14 +67,13 @@ AqlFeature* AqlFeature::lease() {
void AqlFeature::unlease() {
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
AqlFeature* aql = AqlFeature::_AQL;
if (aql == nullptr) {
return;
}
TRI_ASSERT(aql != nullptr);
--aql->_numberLeases;
}
void AqlFeature::start() {
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
TRI_ASSERT(_AQL == nullptr);
_AQL = this;
LOG_TOPIC(DEBUG, Logger::QUERIES) << "AQL feature started";
}

View File

@ -244,7 +244,13 @@ void ApplicationServer::beginShutdown() {
++it) {
if ((*it)->isEnabled()) {
LOG_TOPIC(TRACE, Logger::STARTUP) << (*it)->name() << "::beginShutdown";
try {
(*it)->beginShutdown();
} catch (std::exception const& ex) {
LOG_TOPIC(ERR, Logger::STARTUP) << "caught exception during beginShutdown of feature '" << (*it)->name() << "': " << ex.what();
} catch (...) {
LOG_TOPIC(ERR, Logger::STARTUP) << "caught unknown exception during beginShutdown of feature '" << (*it)->name() << "'";
}
}
}
@ -616,7 +622,13 @@ void ApplicationServer::stop() {
}
LOG_TOPIC(TRACE, Logger::STARTUP) << feature->name() << "::stop";
try {
feature->stop();
} catch (std::exception const& ex) {
LOG_TOPIC(ERR, Logger::STARTUP) << "caught exception during stop of feature '" << feature->name() << "': " << ex.what();
} catch (...) {
LOG_TOPIC(ERR, Logger::STARTUP) << "caught unknown exception during stop of feature '" << feature->name() << "'";
}
feature->state(FeatureState::STOPPED);
reportFeatureProgress(_state, feature->name());
}
@ -630,7 +642,13 @@ void ApplicationServer::unprepare() {
auto feature = *it;
LOG_TOPIC(TRACE, Logger::STARTUP) << feature->name() << "::unprepare";
try {
feature->unprepare();
} catch (std::exception const& ex) {
LOG_TOPIC(ERR, Logger::STARTUP) << "caught exception during unprepare of feature '" << feature->name() << "': " << ex.what();
} catch (...) {
LOG_TOPIC(ERR, Logger::STARTUP) << "caught unknown exception during unprepare of feature '" << feature->name() << "'";
}
feature->state(FeatureState::UNPREPARED);
reportFeatureProgress(_state, feature->name());
}