From b186aebd8d83cb2611e063838dbfc22a43f5067f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Max=20Neunh=C3=B6ffer?= Date: Tue, 5 Nov 2019 16:32:33 +0100 Subject: [PATCH] Fix immediate shutdown after startup failure. (#10365) * Add missing dependencies to IResearchAnalyzerFeature * First all features beginShutdown, then stop. This is for the case of immediate shutdown if the startup did not work. --- .../IResearch/IResearchAnalyzerFeature.cpp | 4 ++++ lib/ApplicationFeatures/ApplicationServer.cpp | 21 ++++++++++++++++++- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/arangod/IResearch/IResearchAnalyzerFeature.cpp b/arangod/IResearch/IResearchAnalyzerFeature.cpp index ec0b374bc4..84f373911f 100644 --- a/arangod/IResearch/IResearchAnalyzerFeature.cpp +++ b/arangod/IResearch/IResearchAnalyzerFeature.cpp @@ -978,6 +978,10 @@ IResearchAnalyzerFeature::IResearchAnalyzerFeature(arangodb::application_feature // used for getting the system database // containing the persisted configuration startsAfter("SystemDatabase"); + startsAfter("CommunicationPhase"); + startsAfter("Aql"); + startsAfter("OptimizerRules"); + startsAfter("QueryRegistry"); } /*static*/ bool IResearchAnalyzerFeature::canUse( // check permissions diff --git a/lib/ApplicationFeatures/ApplicationServer.cpp b/lib/ApplicationFeatures/ApplicationServer.cpp index b4d1660fb2..ea48d07150 100644 --- a/lib/ApplicationFeatures/ApplicationServer.cpp +++ b/lib/ApplicationFeatures/ApplicationServer.cpp @@ -683,6 +683,26 @@ void ApplicationServer::start() { LOG_TOPIC("4ec19", ERR, Logger::STARTUP) << res.errorMessage() << ". shutting down"; LOG_TOPIC("51732", TRACE, Logger::STARTUP) << "aborting startup, now stopping and unpreparing all features"; + + // try to stop all feature that we just started + for (auto it = _orderedFeatures.rbegin(); it != _orderedFeatures.rend(); ++it) { + auto feature = *it; + if (!feature->isEnabled()) { + continue; + } + if (feature->state() == ApplicationFeature::State::STARTED) { + LOG_TOPIC("e5cfe", TRACE, Logger::STARTUP) + << "forcefully beginning stop of feature '" << feature->name() << "'"; + try { + feature->beginShutdown(); + } catch (...) { + // ignore errors on shutdown + LOG_TOPIC("13224", TRACE, Logger::STARTUP) + << "caught exception while stopping feature '" << feature->name() << "'"; + } + } + } + // try to stop all feature that we just started for (auto it = _orderedFeatures.rbegin(); it != _orderedFeatures.rend(); ++it) { auto feature = *it; @@ -693,7 +713,6 @@ void ApplicationServer::start() { LOG_TOPIC("e5cfd", TRACE, Logger::STARTUP) << "forcefully stopping feature '" << feature->name() << "'"; try { - feature->beginShutdown(); feature->stop(); feature->state(ApplicationFeature::State::STOPPED); } catch (...) {