8000 protoype for forceOneShardAttributeValue by jsteemann · Pull Request #14707 · arangodb/arangodb · GitHub
[go: up one dir, main page]

Skip to content

protoype for forceOneShardAttributeValue #14707

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Sep 7, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ v3.8.1 (XXXX-XX-XX)
the option, the query's execution plan will contain the "cluster-one-shard"
optimizer rule.

* Reduce internal priority of AQL execution. This prevents possible deadlocks
with modification operations in a cluster and replicationFactor >= 2, and can
also improve responsiveness under high load of AQL queries.

* Updated arangosync to 2.6.0.

* Added protocol specific metrics: histogram about request body size, total
number of HTTP/2 connections and total number of VST connections.

Expand Down
2 changes: 1 addition & 1 deletion arangod/Aql/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ futures::Future<Result> finishDBServerParts(Query& query, ErrorCode errorCode) {
network::RequestOptions options;
options.database = query.vocbase().name();
options.timeout = network::Timeout(60.0); // Picked arbitrarily
options.continuationLane = RequestLane::CLUSTER_AQL_CONTINUATION;
options.continuationLane = RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR;
// options.skipScheduler = true;

VPackBuffer<uint8_t> body;
Expand Down
8 changes: 8 additions & 0 deletions arangod/Aql/RestAqlHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,3 +851,11 @@ RestStatus RestAqlHandler::handleFinishQuery(std::string const& idString) {
generateResult(rest::ResponseCode::OK, std::move(buffer));
}));
}

RequestLane RestAqlHandler::lane() const {
if (ServerState::instance()->isCoordinator()) {
return RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR;
} else {
return RequestLane::CLUSTER_AQL;
}
}
2 changes: 1 addition & 1 deletion arangod/Aql/RestAqlHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class RestAqlHandler : public RestVocbaseBaseHandler {

public:
char const* name() const override final { return "RestAqlHandler"; }
RequestLane lane() const override final { return RequestLane::CLUSTER_AQL; }
RequestLane lane() const override final;
RestStatus execute() override;
RestStatus continueExecute() override;
void shutdownExecute(bool isFinalized) noexcept override;
Expand Down
62 changes: 33 additions & 29 deletions arangod/Aql/SharedQueryState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "ApplicationFeatures/ApplicationServer.h"
#include "Basics/Exceptions.h"
#include "Basics/ScopeGuard.h"
#include "Cluster/ServerState.h"
#include "RestServer/QueryRegistryFeature.h"
#include "Scheduler/Scheduler.h"
#include "Scheduler/SchedulerFeature.h"
Expand Down Expand Up @@ -129,34 +130,37 @@ void SharedQueryState::queueHandler() {
return;
}

bool queued =
scheduler->queue(RequestLane::CLUSTER_AQL_CONTINUATION,
[self = shared_from_this(), cb = _wakeupCb, v = _cbVersion]() {
std::unique_lock<std::mutex> lck(self->_mutex, std::defer_lock);

do {
bool cntn = false;
try {
cntn = cb();
} catch (...) {
}

lck.lock();
if (v == self->_cbVersion) {
unsigned c = self->_numWakeups--;
TRI_ASSERT(c > 0);
if (c == 1 || !cntn || !self->_valid) {
break;
}
} else {
return;
}
lck.unlock();
} while (true);

TRI_ASSERT(lck);
self->queueHandler();
});
auto const lane = ServerState::instance()->isCoordinator()
? RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR
: RequestLane::CLUSTER_AQL;

bool queued = scheduler->queue(lane, [self = shared_from_this(),
cb = _wakeupCb, v = _cbVersion]() {
std::unique_lock<std::mutex> lck(self->_mutex, std::defer_lock);

do {
bool cntn = false;
try {
cntn = cb();
} catch (...) {
}

lck.lock();
if (v == self->_cbVersion) {
unsigned c = self->_numWakeups--;
TRI_ASSERT(c > 0);
if (c == 1 || !cntn || !self->_valid) {
break;
}
} else {
return;
}
lck.unlock();
} while (true);

TRI_ASSERT(lck);
self->queueHandler();
});

if (!queued) { // just invalidate
_wakeupCb = nullptr;
Expand All @@ -168,7 +172,7 @@ void SharedQueryState::queueHandler() {
bool SharedQueryState::queueAsyncTask(fu2::unique_function<void()> cb) {
Scheduler* scheduler = SchedulerFeature::SCHEDULER;
if (scheduler) {
return scheduler->queue(RequestLane::CLIENT_AQL, std::move(cb));
return scheduler->queue(RequestLane::CLUSTER_AQL, std::move(cb));
}
return false;
}
19 changes: 10 additions & 9 deletions arangod/GeneralServer/RequestLane.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ enum class RequestLane {
// V8 or having high priority.
CLUSTER_INTERNAL,

// For requests from the DBserver to the Coordinator or
// from the Coordinator to the DBserver. Using AQL
// these have Medium priority.
// Internal AQL requests, or continuations. Low priority.
CLUSTER_AQL,

// For future continuations initiated as part of an AQL request from the
// DBserver to the Coordinator or from the Coordinator to the DBserver.
// These have High priority.
CLUSTER_AQL_CONTINUATION,
// For requests from the DBserver to the Coordinator, and continuations on the
// Coordinator.
// These have medium priority. Because client requests made against the
// RestCursorHandler (with lane CLIENT_AQL) might block and need these to
// finish. Ongoing low priority requests can also prevent low priority lanes
// from being worked on, having the same effect.
CLUSTER_AQL_INTERNAL_COORDINATOR,

// For requests from the from the Coordinator to the
// DBserver using V8.
Expand Down Expand Up @@ -142,9 +143,9 @@ inline RequestPriority PriorityRequestLane(RequestLane lane) {
case RequestLane::CLUSTER_INTERNAL:
return RequestPriority::HIGH;
case RequestLane::CLUSTER_AQL:
return RequestPriority::LOW;
case RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR:
return RequestPriority::MED;
case RequestLane::CLUSTER_AQL_CONTINUATION:
return RequestPriority::HIGH;
case RequestLane::CLUSTER_V8:
return RequestPriority::LOW;
case RequestLane::CLUSTER_ADMIN:
Expand Down
88 changes: 88 additions & 0 deletions tests/js/client/server_parameters/test-statistics-enabled-false.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/*jshint globalstrict:false, strict:false */
/* global getOptions, assertEqual, assertTrue, arango */

////////////////////////////////////////////////////////////////////////////////
/// @brief test for security-related server options
///
/// @file
///
/// DISCLAIMER
///
/// Copyright 2010-2012 triagens GmbH, Cologne, Germany
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///
/// Copyright holder is ArangoDB Inc, Cologne, Germany
///
/// @author Jan Steemann
/// @author Copyright 2019, ArangoDB Inc, Cologne, Germany
////////////////////////////////////////////////////////////////////////////////

if (getOptions === true) {
return {
'server.statistics': "false",
'server.export-metrics-api': "true",
};
}

const jsunity = require('jsunity');

function testSuite() {
return {
testGetAdminStatistics : function() {
let res = arango.GET("/_admin/statistics");
assertTrue(res.error);
assertEqual(404, res.code);
},

testGetAdminStatisticsDescription : function() {
let res = arango.GET("/_admin/statistics-description");
assertTrue(res.error);
assertEqual(404, res.code);
},

testGetMetrics : function() {
let metrics = {};
String(arango.GET("/_admin/metrics/v2"))
.split("\n")
.filter((line) => line.match(/^[^#]/))
.filter((line) => line.match(/^arangodb_/))
.forEach((line) => {
let name = line.replace(/[ \{].*$/g, '');
let value = Number(line.replace(/^.+ (\d+)$/, '$1'));
metrics[name] = value;
});

const expected = [
"arangodb_process_statistics_minor_page_faults_total",
"arangodb_process_statistics_major_page_faults_total",
"arangodb_process_statistics_user_time",
"arangodb_process_statistics_system_time",
"arangodb_process_statistics_number_of_threads",
"arangodb_process_statistics_resident_set_size",
"arangodb_process_statistics_resident_set_size_percent",
"arangodb_process_statistics_virtual_memory_size",
"arangodb_server_statistics_physical_memory",
"arangodb_server_statistics_server_uptime_total",
];

expected.forEach((name) => {
assertTrue(metrics.hasOwnProperty(name), name);
assertEqual("number", typeof metrics[name], name);
});
},
};
}

jsunity.run(testSuite);
return jsunity.done();
0