mirror of https://gitee.com/bigwinds/arangodb
Merge
This commit is contained in:
commit
42f12d0ac6
|
@ -454,7 +454,10 @@ QueryResult Query::prepare (QueryRegistry* registry) {
|
||||||
auto otherJsonString =
|
auto otherJsonString =
|
||||||
otherPlan->toJson(parser->ast(), TRI_UNKNOWN_MEM_ZONE, true).toString();
|
otherPlan->toJson(parser->ast(), TRI_UNKNOWN_MEM_ZONE, true).toString();
|
||||||
std::cout << "deserialised plan: \n" << otherJsonString << "\n";
|
std::cout << "deserialised plan: \n" << otherJsonString << "\n";
|
||||||
TRI_ASSERT(otherJsonString == JsonString); */
|
//TRI_ASSERT(otherJsonString == JsonString); */
|
||||||
|
|
||||||
|
// varsUsedLater and varsValid are unordered_sets and so their orders
|
||||||
|
// are not the same in the serialised and deserialised plans
|
||||||
|
|
||||||
enterState(EXECUTION);
|
enterState(EXECUTION);
|
||||||
ExecutionEngine* engine(ExecutionEngine::instanciateFromPlan(registry, this, plan.get(), planRegisters));
|
ExecutionEngine* engine(ExecutionEngine::instanciateFromPlan(registry, this, plan.get(), planRegisters));
|
||||||
|
|
|
@ -690,11 +690,6 @@
|
||||||
delete SYS_EXECUTE_EXTERNAL;
|
delete SYS_EXECUTE_EXTERNAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (typeof SYS_EXECUTE_EXTERNAL_AND_WAIT !== "undefined") {
|
|
||||||
exports.executeExternalAndWait = SYS_EXECUTE_EXTERNAL_AND_WAIT;
|
|
||||||
delete SYS_EXECUTE_EXTERNAL_AND_WAIT;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief executeExternalAndWait - instantly waits for the exit, returns
|
/// @brief executeExternalAndWait - instantly waits for the exit, returns
|
||||||
/// joint result.
|
/// joint result.
|
||||||
|
|
|
@ -424,6 +424,7 @@ function executeAndWait (cmd, args) {
|
||||||
var startTime = time();
|
var startTime = time();
|
||||||
var res = executeExternalAndWait(cmd, args);
|
var res = executeExternalAndWait(cmd, args);
|
||||||
var deltaTime = time() - startTime;
|
var deltaTime = time() - startTime;
|
||||||
|
var errorMessage = ' - ';
|
||||||
|
|
||||||
if (res.status === "TERMINATED") {
|
if (res.status === "TERMINATED") {
|
||||||
print("Finished: " + res.status + " Exitcode: " + res.exit + " Time Elapsed: " + deltaTime);
|
print("Finished: " + res.status + " Exitcode: " + res.exit + " Time Elapsed: " + deltaTime);
|
||||||
|
@ -435,30 +436,26 @@ function executeAndWait (cmd, args) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (res.status === "ABORTED") {
|
else if (res.status === "ABORTED") {
|
||||||
var toppid = executeExternal("/usr/bin/top", ["-b", "-n1"]);
|
// var toppid = executeExternal("/usr/bin/top", ["-b", "-n1"]);
|
||||||
statusExternal(toppid, true);
|
if (typeof(res.errorMessage) !== 'undefined') {
|
||||||
print("Finished: " + res.status + " Signal: " + res.signal + " Time Elapsed: " + deltaTime);
|
errorMessage += res.errorMessage;
|
||||||
if (res.signal === 10) {
|
|
||||||
return {
|
|
||||||
status: true,
|
|
||||||
message: "irregular termination: " + res.status + " Exit-Signal: " + res.signal +
|
|
||||||
" Handling Signal 10 as non-error.",
|
|
||||||
duration: deltaTime
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
else {
|
// statusExternal(toppid, true);
|
||||||
return {
|
print("Finished: " + res.status + " Signal: " + res.signal + " Time Elapsed: " + deltaTime + errorMessage);
|
||||||
status: false,
|
|
||||||
message: "irregular termination: " + res.status + " Exit-Signal: " + res.signal,
|
|
||||||
duration: deltaTime
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
print("Finished: " + res.status + " Exitcode: " + res.exit + " Time Elapsed: " + deltaTime);
|
|
||||||
return {
|
return {
|
||||||
status: false,
|
status: false,
|
||||||
message: "irregular termination: " + res.status + " Exit-Code: " + res.exit,
|
message: "irregular termination: " + res.status + " Exit-Signal: " + res.signal + errorMessage,
|
||||||
|
duration: deltaTime
|
||||||
|
};
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (typeof(res.errorMessage) !== 'undefined') {
|
||||||
|
errorMessage += res.errorMessage;
|
||||||
|
}
|
||||||
|
print("Finished: " + res.status + " Exitcode: " + res.exit + " Time Elapsed: " + deltaTime + errorMessage);
|
||||||
|
return {
|
||||||
|
status: false,
|
||||||
|
message: "irregular termination: " + res.status + " Exit-Code: " + res.exit + errorMessage,
|
||||||
duration: deltaTime
|
duration: deltaTime
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
#include "Basics/string-buffer.h"
|
#include "Basics/string-buffer.h"
|
||||||
#include "Basics/locks.h"
|
#include "Basics/locks.h"
|
||||||
#include "Basics/logging.h"
|
#include "Basics/logging.h"
|
||||||
|
#include "Basics/StringUtils.h"
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
// --SECTION-- private types
|
// --SECTION-- private types
|
||||||
|
@ -975,6 +977,10 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
||||||
|
|
||||||
if (i == ExternalProcesses._length) {
|
if (i == ExternalProcesses._length) {
|
||||||
TRI_UnlockMutex(&ExternalProcessesLock);
|
TRI_UnlockMutex(&ExternalProcessesLock);
|
||||||
|
status._errorMessage =
|
||||||
|
std::string("the pid you're looking for is not in our list: ") +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_pid);
|
||||||
|
status._status = TRI_EXT_NOT_FOUND;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -993,12 +999,41 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
||||||
}
|
}
|
||||||
res = waitpid(external->_pid, &loc, opts);
|
res = waitpid(external->_pid, &loc, opts);
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
external->_exitStatus = 0;
|
if (wait) {
|
||||||
|
status._errorMessage =
|
||||||
|
std::string("waitpid returned 0 for pid while it shouldn't ") +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_pid);
|
||||||
|
if (WIFEXITED(loc)) {
|
||||||
|
external->_status = TRI_EXT_TERMINATED;
|
||||||
|
external->_exitStatus = WEXITSTATUS(loc);
|
||||||
|
}
|
||||||
|
else if (WIFSIGNALED(loc)) {
|
||||||
|
external->_status = TRI_EXT_ABORTED;
|
||||||
|
external->_exitStatus = WTERMSIG(loc);
|
||||||
|
}
|
||||||
|
else if (WIFSTOPPED(loc)) {
|
||||||
|
external->_status = TRI_EXT_STOPPED;
|
||||||
|
external->_exitStatus = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
external->_status = TRI_EXT_ABORTED;
|
||||||
|
external->_exitStatus = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
external->_exitStatus = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (res == -1) {
|
else if (res == -1) {
|
||||||
|
int err = errno;
|
||||||
LOG_WARNING("waitpid returned error for pid %d: %s",
|
LOG_WARNING("waitpid returned error for pid %d: %s",
|
||||||
(int) external->_pid,
|
(int) external->_pid,
|
||||||
TRI_errno_string(errno));
|
TRI_errno_string(err));
|
||||||
|
status._errorMessage =
|
||||||
|
std::string("waitpid returned error for pid ") +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_pid) +
|
||||||
|
std::string(": ") +
|
||||||
|
std::string(TRI_errno_string(err));
|
||||||
}
|
}
|
||||||
else if (static_cast<TRI_pid_t>(external->_pid) == static_cast<TRI_pid_t>(res)) {
|
else if (static_cast<TRI_pid_t>(external->_pid) == static_cast<TRI_pid_t>(res)) {
|
||||||
if (WIFEXITED(loc)) {
|
if (WIFEXITED(loc)) {
|
||||||
|
@ -1025,6 +1060,11 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
||||||
fprintf(stderr, "unexpected waitpid result for pid %d: %d",
|
fprintf(stderr, "unexpected waitpid result for pid %d: %d",
|
||||||
(int) external->_pid,
|
(int) external->_pid,
|
||||||
(int) res);
|
(int) res);
|
||||||
|
status._errorMessage =
|
||||||
|
std::string("unexpected waitpid result for pid ") +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_pid) +
|
||||||
|
std::string(": ") +
|
||||||
|
triagens::basics::StringUtils::itoa(res);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (wait) {
|
if (wait) {
|
||||||
|
@ -1033,12 +1073,20 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
||||||
if (result == WAIT_FAILED) {
|
if (result == WAIT_FAILED) {
|
||||||
LOG_WARNING("could not wait for subprocess with PID '%ud'",
|
LOG_WARNING("could not wait for subprocess with PID '%ud'",
|
||||||
external->_pid);
|
external->_pid);
|
||||||
|
external->_errorMessage =
|
||||||
|
std::string("could not wait for subprocess with PID '",) +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_pid) +
|
||||||
|
std::string("'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
DWORD exitCode = STILL_ACTIVE;
|
DWORD exitCode = STILL_ACTIVE;
|
||||||
if (! GetExitCodeProcess(external->_process , &exitCode)) {
|
if (! GetExitCodeProcess(external->_process , &exitCode)) {
|
||||||
LOG_WARNING("exit status could not be determined for PID '%ud'",
|
LOG_WARNING("exit status could not be determined for PID '%ud'",
|
||||||
external->_pid);
|
external->_pid);
|
||||||
|
status._errorMessage =
|
||||||
|
std::string("exit status could not be determined for PID '") +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_pid) +
|
||||||
|
std::string("'");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (exitCode == STILL_ACTIVE) {
|
if (exitCode == STILL_ACTIVE) {
|
||||||
|
@ -1058,6 +1106,11 @@ TRI_external_status_t TRI_CheckExternalProcess (TRI_external_id_t pid,
|
||||||
fprintf(stderr, "unexpected process status %d: %d",
|
fprintf(stderr, "unexpected process status %d: %d",
|
||||||
(int) external->_status,
|
(int) external->_status,
|
||||||
(int) external->_exitStatus);
|
(int) external->_exitStatus);
|
||||||
|
status._errorMessage =
|
||||||
|
std::string("unexpected process status ") +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_status) +
|
||||||
|
std::string(": ") +
|
||||||
|
triagens::basics::StringUtils::itoa(external->_exitStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
status._status = external->_status;
|
status._status = external->_status;
|
||||||
|
|
|
@ -134,6 +134,7 @@ TRI_external_t;
|
||||||
typedef struct TRI_external_status_s {
|
typedef struct TRI_external_status_s {
|
||||||
TRI_external_status_e _status;
|
TRI_external_status_e _status;
|
||||||
int _exitStatus;
|
int _exitStatus;
|
||||||
|
std::string _errorMessage;
|
||||||
}
|
}
|
||||||
TRI_external_status_t;
|
TRI_external_status_t;
|
||||||
|
|
||||||
|
|
|
@ -3011,7 +3011,10 @@ static v8::Handle<v8::Value> JS_StatusExternal (v8::Arguments const& argv) {
|
||||||
else if (external._status == TRI_EXT_ABORTED) {
|
else if (external._status == TRI_EXT_ABORTED) {
|
||||||
result->Set(v8::String::New("signal"), v8::Number::New(external._exitStatus));
|
result->Set(v8::String::New("signal"), v8::Number::New(external._exitStatus));
|
||||||
}
|
}
|
||||||
|
if (external._errorMessage.length() > 0) {
|
||||||
|
result->Set(v8::String::New("errorMessage"), v8::String::New(external._errorMessage.c_str(),
|
||||||
|
external._errorMessage.size()));
|
||||||
|
}
|
||||||
// return the result
|
// return the result
|
||||||
return scope.Close(result);
|
return scope.Close(result);
|
||||||
}
|
}
|
||||||
|
@ -3154,7 +3157,11 @@ static v8::Handle<v8::Value> JS_ExecuteAndWaitExternal (v8::Arguments const& arg
|
||||||
else if (external_status._status == TRI_EXT_ABORTED) {
|
else if (external_status._status == TRI_EXT_ABORTED) {
|
||||||
result->Set(v8::String::New("signal"), v8::Number::New(external_status._exitStatus));
|
result->Set(v8::String::New("signal"), v8::Number::New(external_status._exitStatus));
|
||||||
}
|
}
|
||||||
|
if (external_status._errorMessage.length() > 0) {
|
||||||
|
result->Set(v8::String::New("errorMessage"),
|
||||||
|
v8::String::New(external_status._errorMessage.c_str(),
|
||||||
|
external_status._errorMessage.size()));
|
||||||
|
}
|
||||||
// return the result
|
// return the result
|
||||||
return scope.Close(result);
|
return scope.Close(result);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue