mirror of https://gitee.com/bigwinds/arangodb
Mark blocking threads as such in two places to allow additional threads.
This fixes some cluster hang bugs in larger clusters.
This commit is contained in:
parent
a79730a4ff
commit
2844f02a74
|
@ -32,6 +32,7 @@
|
|||
#include "Aql/ExecutionBlock.h"
|
||||
#include "Basics/ConditionLocker.h"
|
||||
#include "Basics/StringUtils.h"
|
||||
#include "Dispatcher/DispatcherThread.h"
|
||||
#include "HttpServer/HttpServer.h"
|
||||
#include "HttpServer/HttpHandlerFactory.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
|
@ -694,16 +695,28 @@ void RestAqlHandler::handleUseQuery (std::string const& operation,
|
|||
Json answerBody(Json::Object, 3);
|
||||
|
||||
if (operation == "lock") {
|
||||
// Mark current thread as potentially blocking:
|
||||
auto currentThread = triagens::rest::DispatcherThread::currentDispatcherThread;
|
||||
|
||||
if (currentThread != nullptr) {
|
||||
triagens::rest::DispatcherThread::currentDispatcherThread->blockThread();
|
||||
}
|
||||
int res = TRI_ERROR_INTERNAL;
|
||||
try {
|
||||
res = query->trx()->lockCollections();
|
||||
}
|
||||
catch (...) {
|
||||
LOG_ERROR("lock lead to an exception");
|
||||
if (currentThread != nullptr) {
|
||||
triagens::rest::DispatcherThread::currentDispatcherThread->unblockThread();
|
||||
}
|
||||
generateError(HttpResponse::SERVER_ERROR, TRI_ERROR_HTTP_SERVER_ERROR,
|
||||
"lock lead to an exception");
|
||||
return;
|
||||
}
|
||||
if (currentThread != nullptr) {
|
||||
triagens::rest::DispatcherThread::currentDispatcherThread->unblockThread();
|
||||
}
|
||||
answerBody("error", res == TRI_ERROR_NO_ERROR ? Json(false) : Json(true))
|
||||
("code", Json(static_cast<double>(res)));
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "Basics/tri-strings.h"
|
||||
#include "Cluster/ServerState.h"
|
||||
#include "Cluster/v8-cluster.h"
|
||||
#include "Dispatcher/DispatcherThread.h"
|
||||
#include "Dispatcher/ApplicationDispatcher.h"
|
||||
#include "Rest/HttpRequest.h"
|
||||
#include "Scheduler/ApplicationScheduler.h"
|
||||
|
@ -358,7 +359,15 @@ ApplicationV8::V8Context* ApplicationV8::enterContext (std::string const& name,
|
|||
|
||||
while (_freeContexts[name].empty() && ! _stopping) {
|
||||
LOG_DEBUG("waiting for unused V8 context");
|
||||
auto currentThread = triagens::rest::DispatcherThread::currentDispatcherThread;
|
||||
|
||||
if (currentThread != nullptr) {
|
||||
triagens::rest::DispatcherThread::currentDispatcherThread->blockThread();
|
||||
}
|
||||
guard.wait();
|
||||
if (currentThread != nullptr) {
|
||||
triagens::rest::DispatcherThread::currentDispatcherThread->unblockThread();
|
||||
}
|
||||
}
|
||||
|
||||
// in case we are in the shutdown phase, do not enter a context!
|
||||
|
|
Loading…
Reference in New Issue