mirror of https://gitee.com/bigwinds/arangodb
fixed shutdown issues
This commit is contained in:
parent
7250ba29ee
commit
bf209397cd
|
@ -28,6 +28,7 @@
|
||||||
#include <velocypack/Iterator.h>
|
#include <velocypack/Iterator.h>
|
||||||
#include <velocypack/velocypack-aliases.h>
|
#include <velocypack/velocypack-aliases.h>
|
||||||
|
|
||||||
|
#include "ApplicationFeatures/ApplicationServer.h"
|
||||||
#include "Aql/Function.h"
|
#include "Aql/Function.h"
|
||||||
#include "Aql/Query.h"
|
#include "Aql/Query.h"
|
||||||
#include "Basics/Exceptions.h"
|
#include "Basics/Exceptions.h"
|
||||||
|
@ -1758,9 +1759,10 @@ AqlValue Functions::Sleep(arangodb::aql::Query* query,
|
||||||
|
|
||||||
if (query->killed()) {
|
if (query->killed()) {
|
||||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_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());
|
return AqlValue(arangodb::basics::VelocyPackHelper::NullValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
|
|
||||||
#include "Query.h"
|
#include "Query.h"
|
||||||
|
|
||||||
#include "ApplicationFeatures/ApplicationServer.h"
|
|
||||||
#include "Aql/AqlItemBlock.h"
|
#include "Aql/AqlItemBlock.h"
|
||||||
#include "Aql/AqlTransaction.h"
|
#include "Aql/AqlTransaction.h"
|
||||||
#include "Aql/ExecutionBlock.h"
|
#include "Aql/ExecutionBlock.h"
|
||||||
|
@ -43,7 +42,6 @@
|
||||||
#include "Cluster/ServerState.h"
|
#include "Cluster/ServerState.h"
|
||||||
#include "Logger/Logger.h"
|
#include "Logger/Logger.h"
|
||||||
#include "RestServer/AqlFeature.h"
|
#include "RestServer/AqlFeature.h"
|
||||||
#include "RestServer/QueryRegistryFeature.h"
|
|
||||||
#include "StorageEngine/TransactionState.h"
|
#include "StorageEngine/TransactionState.h"
|
||||||
#include "Transaction/Methods.h"
|
#include "Transaction/Methods.h"
|
||||||
#include "Transaction/StandaloneContext.h"
|
#include "Transaction/StandaloneContext.h"
|
||||||
|
@ -90,7 +88,6 @@ Query::Query(bool contextOwnedByExterior, TRI_vocbase_t* vocbase,
|
||||||
_trx(nullptr),
|
_trx(nullptr),
|
||||||
_warnings(),
|
_warnings(),
|
||||||
_startTime(TRI_microtime()),
|
_startTime(TRI_microtime()),
|
||||||
_queryRegistry(application_features::ApplicationServer::getFeature<arangodb::QueryRegistryFeature>("QueryRegistry")),
|
|
||||||
_part(part),
|
_part(part),
|
||||||
_contextOwnedByExterior(contextOwnedByExterior),
|
_contextOwnedByExterior(contextOwnedByExterior),
|
||||||
_killed(false),
|
_killed(false),
|
||||||
|
@ -170,7 +167,6 @@ Query::Query(bool contextOwnedByExterior, TRI_vocbase_t* vocbase,
|
||||||
_trx(nullptr),
|
_trx(nullptr),
|
||||||
_warnings(),
|
_warnings(),
|
||||||
_startTime(TRI_microtime()),
|
_startTime(TRI_microtime()),
|
||||||
_queryRegistry(application_features::ApplicationServer::getFeature<arangodb::QueryRegistryFeature>("QueryRegistry")),
|
|
||||||
_part(part),
|
_part(part),
|
||||||
_contextOwnedByExterior(contextOwnedByExterior),
|
_contextOwnedByExterior(contextOwnedByExterior),
|
||||||
_killed(false),
|
_killed(false),
|
||||||
|
|
|
@ -55,8 +55,6 @@ namespace velocypack {
|
||||||
class Builder;
|
class Builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
class QueryRegistryFeature;
|
|
||||||
|
|
||||||
namespace aql {
|
namespace aql {
|
||||||
|
|
||||||
struct AstNode;
|
struct AstNode;
|
||||||
|
@ -342,8 +340,6 @@ class Query {
|
||||||
/// @brief query start time
|
/// @brief query start time
|
||||||
double _startTime;
|
double _startTime;
|
||||||
|
|
||||||
QueryRegistryFeature const* _queryRegistry;
|
|
||||||
|
|
||||||
/// @brief the query part
|
/// @brief the query part
|
||||||
QueryPart const _part;
|
QueryPart const _part;
|
||||||
|
|
||||||
|
|
|
@ -118,8 +118,7 @@ Query* QueryRegistry::open(TRI_vocbase_t* vocbase, QueryId id) {
|
||||||
|
|
||||||
auto m = _queries.find(vocbase->name());
|
auto m = _queries.find(vocbase->name());
|
||||||
if (m == _queries.end()) {
|
if (m == _queries.end()) {
|
||||||
m = _queries.emplace(vocbase->name(),
|
return nullptr;
|
||||||
std::unordered_map<QueryId, QueryInfo*>()).first;
|
|
||||||
}
|
}
|
||||||
auto q = m->second.find(id);
|
auto q = m->second.find(id);
|
||||||
if (q == m->second.end()) {
|
if (q == m->second.end()) {
|
||||||
|
@ -290,6 +289,10 @@ void QueryRegistry::destroyAll() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (auto& p : allQueries) {
|
for (auto& p : allQueries) {
|
||||||
destroy(p.first, p.second, TRI_ERROR_SHUTTING_DOWN);
|
try {
|
||||||
|
destroy(p.first, p.second, TRI_ERROR_SHUTTING_DOWN);
|
||||||
|
} catch (...) {
|
||||||
|
// ignore any errors here
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@
|
||||||
#include "RestServer/QueryRegistryFeature.h"
|
#include "RestServer/QueryRegistryFeature.h"
|
||||||
#include "RestServer/TraverserEngineRegistryFeature.h"
|
#include "RestServer/TraverserEngineRegistryFeature.h"
|
||||||
|
|
||||||
|
|
||||||
using namespace arangodb;
|
using namespace arangodb;
|
||||||
using namespace arangodb::application_features;
|
using namespace arangodb::application_features;
|
||||||
|
|
||||||
|
@ -68,14 +67,13 @@ AqlFeature* AqlFeature::lease() {
|
||||||
void AqlFeature::unlease() {
|
void AqlFeature::unlease() {
|
||||||
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
|
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
|
||||||
AqlFeature* aql = AqlFeature::_AQL;
|
AqlFeature* aql = AqlFeature::_AQL;
|
||||||
if (aql == nullptr) {
|
TRI_ASSERT(aql != nullptr);
|
||||||
return;
|
|
||||||
}
|
|
||||||
--aql->_numberLeases;
|
--aql->_numberLeases;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AqlFeature::start() {
|
void AqlFeature::start() {
|
||||||
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
|
MUTEX_LOCKER(locker, AqlFeature::_aqlFeatureMutex);
|
||||||
|
TRI_ASSERT(_AQL == nullptr);
|
||||||
_AQL = this;
|
_AQL = this;
|
||||||
LOG_TOPIC(DEBUG, Logger::QUERIES) << "AQL feature started";
|
LOG_TOPIC(DEBUG, Logger::QUERIES) << "AQL feature started";
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,13 @@ void ApplicationServer::beginShutdown() {
|
||||||
++it) {
|
++it) {
|
||||||
if ((*it)->isEnabled()) {
|
if ((*it)->isEnabled()) {
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << (*it)->name() << "::beginShutdown";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << (*it)->name() << "::beginShutdown";
|
||||||
(*it)->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";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << feature->name() << "::stop";
|
||||||
feature->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);
|
feature->state(FeatureState::STOPPED);
|
||||||
reportFeatureProgress(_state, feature->name());
|
reportFeatureProgress(_state, feature->name());
|
||||||
}
|
}
|
||||||
|
@ -630,7 +642,13 @@ void ApplicationServer::unprepare() {
|
||||||
auto feature = *it;
|
auto feature = *it;
|
||||||
|
|
||||||
LOG_TOPIC(TRACE, Logger::STARTUP) << feature->name() << "::unprepare";
|
LOG_TOPIC(TRACE, Logger::STARTUP) << feature->name() << "::unprepare";
|
||||||
feature->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);
|
feature->state(FeatureState::UNPREPARED);
|
||||||
reportFeatureProgress(_state, feature->name());
|
reportFeatureProgress(_state, feature->name());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue