diff --git a/arangod/Network/NetworkFeature.cpp b/arangod/Network/NetworkFeature.cpp index 69cbc32753..b188a195cb 100644 --- a/arangod/Network/NetworkFeature.cpp +++ b/arangod/Network/NetworkFeature.cpp @@ -86,14 +86,14 @@ void NetworkFeature::collectOptions(std::shared_ptr opt new UInt64Parameter(&_connectionTtlMilli)); options->addOption("--network.verify-hosts", "verify hosts when using TLS", new BooleanParameter(&_verifyHosts)); - - _gcfunc = [this] (bool canceled) { + + _gcfunc = [this](bool canceled) { if (canceled) { return; } - + _pool->pruneConnections(); - + auto* ci = ClusterInfo::instance(); if (ci != nullptr) { auto failed = ci->getFailedServers(); @@ -101,7 +101,7 @@ void NetworkFeature::collectOptions(std::shared_ptr opt _pool->cancelConnections(f); } } - + if (!application_features::ApplicationServer::isStopping() && !canceled) { auto off = std::chrono::seconds(3); ::queueGarbageCollection(_workItemMutex, _workItem, _gcfunc, off); @@ -129,7 +129,7 @@ void NetworkFeature::prepare() { _pool = std::make_unique(config); _poolPtr.store(_pool.get(), std::memory_order_release); } - + void NetworkFeature::start() { Scheduler* scheduler = SchedulerFeature::SCHEDULER; if (scheduler != nullptr) { // is nullptr in catch tests @@ -149,4 +149,10 @@ void NetworkFeature::beginShutdown() { } } +void NetworkFeature::stop() { + // we might have posted another workItem during shutdown. + std::lock_guard guard(_workItemMutex); + _workItem.reset(); +} + } // namespace arangodb diff --git a/arangod/Network/NetworkFeature.h b/arangod/Network/NetworkFeature.h index 4b41e9d7cb..0ea340cdac 100644 --- a/arangod/Network/NetworkFeature.h +++ b/arangod/Network/NetworkFeature.h @@ -43,6 +43,7 @@ class NetworkFeature final : public application_features::ApplicationFeature { void prepare() override; void start() override; void beginShutdown() override; + void stop() override; /// @brief global connection pool static arangodb::network::ConnectionPool* pool() { @@ -56,12 +57,11 @@ class NetworkFeature final : public application_features::ApplicationFeature { #endif private: - uint32_t _numIOThreads; uint64_t _maxOpenConnections; uint64_t _connectionTtlMilli; bool _verifyHosts; - + std::mutex _workItemMutex; Scheduler::WorkHandle _workItem; /// @brief where rhythm is life, and life is rhythm :) diff --git a/tests/js/client/shell/shell-analyzer-rest-api.js b/tests/js/client/shell/shell-analyzer-rest-api.js index c9341278ff..0f37088790 100644 --- a/tests/js/client/shell/shell-analyzer-rest-api.js +++ b/tests/js/client/shell/shell-analyzer-rest-api.js @@ -246,41 +246,48 @@ function testSuite() { }, testAnalyzerLinks : function() { - let body = JSON.stringify({ - name : name, - type : "text", - properties : { locale: "en.UTF-8", stopwords: [ ] }, - }); + try { + let body = JSON.stringify({ + name : name, + type : "text", + properties : { locale: "en.UTF-8", stopwords: [ ] }, + }); - let result = arango.POST_RAW("/_api/analyzer", body); - assertFalse(result.error); + let result = arango.POST_RAW("/_api/analyzer", body); + assertFalse(result.error); - let col = db._create("ulfColTestLinks"); - let view = db._createView("ulfViewTestLinks", "arangosearch", {}); - var properties = { - links : { - [col.name()] : { - includeAllFields : true, - storeValues : "id", - fields : { - text : { analyzers : [name] } + let col = db._create("ulfColTestLinks"); + let view = db._createView("ulfViewTestLinks", "arangosearch", {}); + var properties = { + links : { + [col.name()] : { + includeAllFields : true, + storeValues : "id", + fields : { + text : { analyzers : [name] } + } } } - } - }; - view.properties(properties); + }; + view.properties(properties); - result = arango.DELETE("/_api/analyzer/" + name); + result = arango.DELETE("/_api/analyzer/" + name); - assertTrue(result.error); - assertEqual(result.code, 409); // can not delete -- referencded by link - assertEqual(result.errorNum, error.ERROR_ARANGO_CONFLICT.code); + assertTrue(result.error); + assertEqual(result.code, 409); // can not delete -- referencded by link + assertEqual(result.errorNum, error.ERROR_ARANGO_CONFLICT.code); - // delete with force - must succeed - result = arango.DELETE("/_api/analyzer/" + name + "?force=true"); - assertFalse(result.error); - - db._drop(col.name()); + // delete with force - must succeed + result = arango.DELETE("/_api/analyzer/" + name + "?force=true"); + assertFalse(result.error); + } finally { + try { + db._drop("ulfColTestLinks"); + } catch (_) {} + try { + db._dropView("ulfViewTestLinks"); + } catch (_) {} + } } }; // return } // end of suite diff --git a/tests/js/common/shell/shell-view-arangosearch.js b/tests/js/common/shell/shell-view-arangosearch.js index a4554621c7..ef7039ee0e 100644 --- a/tests/js/common/shell/shell-view-arangosearch.js +++ b/tests/js/common/shell/shell-view-arangosearch.js @@ -43,6 +43,14 @@ var ERRORS = arangodb.errors; function ViewSuite () { 'use strict'; return { + tearDown : function () { + try { + db._dropView("abc"); + } catch (_) {} + try { + db._dropView("def"); + } catch (_) {} + }, //////////////////////////////////////////////////////////////////////////// /// @brief bad name (empty)