mirror of https://gitee.com/bigwinds/arangodb
Added a stop to Network feature. There is a race condition on the gar… (#9892)
* Added a stop to Network feature. There is a race condition on the garbage collection post * Added cleanup for analyzer test and view test * Update tests/js/client/shell/shell-analyzer-rest-api.js Fixed usage of wrong command
This commit is contained in:
parent
412e5280bc
commit
1b1763c496
|
@ -86,14 +86,14 @@ void NetworkFeature::collectOptions(std::shared_ptr<options::ProgramOptions> 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<options::ProgramOptions> 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<network::ConnectionPool>(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<std::mutex> guard(_workItemMutex);
|
||||
_workItem.reset();
|
||||
}
|
||||
|
||||
} // namespace arangodb
|
||||
|
|
|
@ -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 :)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue