8000 Lower priority of AQL lanes (#14695) · arangodb/arangodb@1fefb9b · GitHub
[go: up one dir, main page]

Skip to content

Commit 1fefb9b

Browse files
goedderzjsteemann
andauthored
Lower priority of AQL lanes (#14695)
Co-authored-by: Jan <jsteemann@users.noreply.github.com>
1 parent c184b51 commit 1fefb9b

File tree

6 files changed

+57
-40
lines changed

6 files changed

+57
-40
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
devel
22
-----
33

4+
* Reduce internal priority of AQL execution. This prevents possible deadlocks
5+
with modification operations in a cluster and replicationFactor >= 2, and can
6+
also improve responsiveness under high load of AQL queries.
7+
48
* Updated arangosync to 2.6.0.
59

610
* Fix a potential multi-threading issue in index creation on coordinators,

arangod/Aql/Query.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1265,7 +1265,7 @@ futures::Future<Result> finishDBServerParts(Query& query, ErrorCode errorCode) {
12651265
network::RequestOptions options;
12661266
options.database = query.vocbase().name();
12671267
options.timeout = network::Timeout(60.0); // Picked arbitrarily
1268-
options.continuationLane = RequestLane::CLUSTER_AQL_CONTINUATION;
1268+
options.continuationLane = RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR;
12691269
// options.skipScheduler = true;
12701270

12711271
VPackBuffer<uint8_t> body;

arangod/Aql/RestAqlHandler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -857,3 +857,11 @@ RestStatus RestAqlHandler::handleFinishQuery(std::string const& idString) {
857857
generateResult(rest::ResponseCode::OK, std::move(buffer));
858858
}));
859859
}
860+
861+
RequestLane RestAqlHandler::lane() const {
862+
if (ServerState::instance()->isCoordinator()) {
863+
return RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR;
864+
} else {
865+
return RequestLane::CLUSTER_AQL;
866+
}
867+
}

arangod/Aql/RestAqlHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class RestAqlHandler : public RestVocbaseBaseHandler {
4242

4343
public:
4444
char const* name() const override final { return "RestAqlHandler"; }
45-
RequestLane lane() const override final { return RequestLane::CLUSTER_AQL; }
45+
RequestLane lane() const override final;
4646
RestStatus execute() override;
4747
RestStatus continueExecute() override;
4848
void shutdownExecute(bool isFinalized) noexcept override;

arangod/Aql/SharedQueryState.cpp

Lines changed: 33 additions & 29 deletions
E30A
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "ApplicationFeatures/ApplicationServer.h"
2727
#include "Basics/Exceptions.h"
2828
#include "Basics/ScopeGuard.h"
29+
#include "Cluster/ServerState.h"
2930
#include "RestServer/QueryRegistryFeature.h"
3031
#include "Scheduler/Scheduler.h"
3132
#include "Scheduler/SchedulerFeature.h"
@@ -129,34 +130,37 @@ void SharedQueryState::queueHandler() {
129130
return;
130131
}
131132

132-
bool queued =
133-
scheduler->queue(RequestLane::CLUSTER_AQL_CONTINUATION,
134-
[self = shared_from_this(), cb = _wakeupCb, v = _cbVersion]() {
135-
std::unique_lock<std::mutex> lck(self->_mutex, std::defer_lock);
136-
137-
do {
138-
bool cntn = false;
139-
try {
140-
cntn = cb();
141-
} catch (...) {
142-
}
143-
144-
lck.lock();
145-
if (v == self->_cbVersion) {
146-
unsigned c = self->_numWakeups--;
147-
TRI_ASSERT(c > 0);
148-
if (c == 1 || !cntn || !self->_valid) {
149-
break;
150-
}
151-
} else {
152-
return;
153-
}
154-
lck.unlock();
155-
} while (true);
156-
157-
TRI_ASSERT(lck);
158-
self->queueHandler();
159-
});
133+
auto const lane = ServerState::instance()->isCoordinator()
134+
? RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR
135+
: RequestLane::CLUSTER_AQL;
136+
137+
bool queued = scheduler->queue(lane, [self = shared_from_this(),
138+
cb = _wakeupCb, v = _cbVersion]() {
139+
std::unique_lock<std::mutex> lck(self->_mutex, std::defer_lock);
140+
141+
do {
142+
bool cntn = false;
143+
try {
144+
cntn = cb();
145+
} catch (...) {
146+
}
147+
148+
lck.lock();
149+
if (v == self->_cbVersion) {
150+
unsigned c = self->_numWakeups--;
151+
TRI_ASSERT(c > 0);
152+
if (c == 1 || !cntn || !self->_valid) {
153+
break;
154+
}
155+
} else {
156+
return;
157+
}
158+
lck.unlock();
159+
} while (true);
160+
161+
TRI_ASSERT(lck);
162+
self->queueHandler();
163+
});
160164

161165
if (!queued) { // just invalidate
162166
_wakeupCb = nullptr;
@@ -168,7 +172,7 @@ void SharedQueryState::queueHandler() {
168172
bool SharedQueryState::queueAsyncTask(fu2::unique_function<void()> cb) {
169173
Scheduler* scheduler = SchedulerFeature::SCHEDULER;
170174
if (scheduler) {
171-
return scheduler->queue(RequestLane::CLIENT_AQL, std::move(cb));
175+
return scheduler->queue(RequestLane::CLUSTER_AQL, std::move(cb));
172176
}
173177
return false;
174178
}

arangod/GeneralServer/RequestLane.h

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,16 @@ enum class RequestLane {
6161
// V8 or having high priority.
6262
CLUSTER_INTERNAL,
6363

64-
// For requests from the DBserver to the Coordinator or
65-
// from the Coordinator to the DBserver. Using AQL
66-
// these have Medium priority.
64+
// Internal AQL requests, or continuations. Low priority.
6765
CLUSTER_AQL,
6866

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

7475
// For requests from the from the Coordinator to the
7576
// DBserver using V8.
@@ -141,9 +142,9 @@ inline RequestPriority PriorityRequestLane(RequestLane lane) {
141142
case RequestLane::CLUSTER_INTERNAL:
142143
return RequestPriority::HIGH;
143144
case RequestLane::CLUSTER_AQL:
145+
return RequestPriority::LOW;
146+
case RequestLane::CLUSTER_AQL_INTERNAL_COORDINATOR:
144147
return RequestPriority::MED;
145-
case RequestLane::CLUSTER_AQL_CONTINUATION:
146-
return RequestPriority::HIGH;
147148
case RequestLane::CLUSTER_V8:
148149
return RequestPriority::LOW;
149150
case RequestLane::CLUSTER_ADMIN:

0 commit comments

Comments
 (0)
0