1
0
Fork 0

Merge branch 'devel' of github.com:triAGENS/ArangoDB into devel

This commit is contained in:
Michael Hackstein 2014-10-20 12:42:21 +02:00
commit c179978980
3 changed files with 66 additions and 17 deletions

View File

@ -235,19 +235,28 @@ int ExecutionBlock::initialize () {
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int ExecutionBlock::shutdown () { int ExecutionBlock::shutdown () {
for (auto it = _dependencies.begin(); it != _dependencies.end(); ++it) { int ret = TRI_ERROR_NO_ERROR;
int res = (*it)->shutdown(); int res;
if (res != TRI_ERROR_NO_ERROR) {
return res;
}
}
for (auto it = _buffer.begin(); it != _buffer.end(); ++it) { for (auto it = _buffer.begin(); it != _buffer.end(); ++it) {
delete *it; delete *it;
} }
_buffer.clear(); _buffer.clear();
return TRI_ERROR_NO_ERROR;
for (auto it = _dependencies.begin(); it != _dependencies.end(); ++it) {
try {
res = (*it)->shutdown();
}
catch (...) {
ret = TRI_ERROR_INTERNAL;
}
if (res != TRI_ERROR_NO_ERROR) {
ret = res;
}
}
return ret;
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
@ -4230,17 +4239,30 @@ size_t DistributeBlock::sendToClient (AqlValue val) {
static void throwExceptionAfterBadSyncRequest (ClusterCommResult* res, static void throwExceptionAfterBadSyncRequest (ClusterCommResult* res,
bool isShutdown) { bool isShutdown) {
if (res->status == CL_COMM_TIMEOUT) { if (res->status == CL_COMM_TIMEOUT) {
std::string errorMessage;
errorMessage += std::string("Timeout in communication with shard '") +
std::string(res->shardID) +
std::string("' on cluster node '") +
std::string(res->serverID) +
std::string("' failed.");
// No reply, we give up: // No reply, we give up:
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_CLUSTER_TIMEOUT, THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_CLUSTER_TIMEOUT,
"timeout in cluster AQL operation"); errorMessage);
} }
if (res->status == CL_COMM_ERROR) { if (res->status == CL_COMM_ERROR) {
std::string errorMessage;
// This could be a broken connection or an Http error: // This could be a broken connection or an Http error:
if (res->result == nullptr || ! res->result->isComplete()) { if (res->result == nullptr || ! res->result->isComplete()) {
// there is no result // there is no result
errorMessage += std::string("Empty result in communication with shard '") +
std::string(res->shardID) +
std::string("' on cluster node '") +
std::string(res->serverID) +
std::string("' failed.");
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_CLUSTER_CONNECTION_LOST, THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_CLUSTER_CONNECTION_LOST,
"lost connection within cluster"); errorMessage);
} }
StringBuffer const& responseBodyBuf(res->result->getBody()); StringBuffer const& responseBodyBuf(res->result->getBody());
@ -4248,20 +4270,39 @@ static void throwExceptionAfterBadSyncRequest (ClusterCommResult* res,
// extract error number and message from response // extract error number and message from response
int errorNum = TRI_ERROR_NO_ERROR; int errorNum = TRI_ERROR_NO_ERROR;
std::string errorMessage;
TRI_json_t* json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, responseBodyBuf.c_str()); TRI_json_t* json = TRI_JsonString(TRI_UNKNOWN_MEM_ZONE, responseBodyBuf.c_str());
if (JsonHelper::getBooleanValue(json, "error", true)) {
errorNum = TRI_ERROR_INTERNAL;
errorMessage += std::string("Error message received from shard '") +
std::string(res->shardID) +
std::string("' on cluster node '") +
std::string(res->serverID) +
std::string("': ");
}
if (TRI_IsArrayJson(json)) { if (TRI_IsArrayJson(json)) {
TRI_json_t const* v; TRI_json_t const* v;
v = TRI_LookupArrayJson(json, "errorNum"); v = TRI_LookupArrayJson(json, "errorNum");
if (TRI_IsNumberJson(v)) { if (TRI_IsNumberJson(v)) {
/* if we've got an error num, error has to be true. */
TRI_ASSERT(errorNum != TRI_ERROR_INTERNAL);
errorNum = static_cast<int>(v->_value._number); errorNum = static_cast<int>(v->_value._number);
} }
v = TRI_LookupArrayJson(json, "errorMessage"); v = TRI_LookupArrayJson(json, "errorMessage");
if (TRI_IsStringJson(v)) { if (TRI_IsStringJson(v)) {
errorMessage = std::string(v->_value._string.data, v->_value._string.length - 1); errorMessage += std::string(v->_value._string.data, v->_value._string.length - 1);
} }
else {
errorMessage += std::string("(No valid error in response)");
}
}
else {
errorMessage += std::string("(No valid response)");
} }
if (json != nullptr) { if (json != nullptr) {

View File

@ -513,6 +513,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
// pick up the remote query ids // pick up the remote query ids
std::unordered_map<std::string, std::string> queryIds; std::unordered_map<std::string, std::string> queryIds;
std::string error;
int count = 0; int count = 0;
int nrok = 0; int nrok = 0;
for (count = (int) shardIds.size(); count > 0; count--) { for (count = (int) shardIds.size(); count > 0; count--) {
@ -537,6 +538,13 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
std::cout << "DB SERVER ANSWERED WITH ERROR: " << res->answer->body() << "\n"; std::cout << "DB SERVER ANSWERED WITH ERROR: " << res->answer->body() << "\n";
} }
} }
else {
error += std::string("Communication with shard '") +
std::string(res->shardID) +
std::string("' on cluster node '") +
std::string(res->serverID) +
std::string("' failed.");
}
delete res; delete res;
} }
@ -544,7 +552,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
if (nrok != (int) shardIds.size()) { if (nrok != (int) shardIds.size()) {
// TODO: provide sensible error message with more details // TODO: provide sensible error message with more details
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, "did not receive response from all shards"); THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_INTERNAL, error);
} }
return queryIds; return queryIds;
@ -742,10 +750,10 @@ ExecutionEngine* ExecutionEngine::instanciateFromPlan (QueryRegistry* queryRegis
} }
TRI_ASSERT(root != nullptr); TRI_ASSERT(root != nullptr);
engine->_root = root;
root->initialize(); root->initialize();
root->initializeCursor(nullptr, 0); root->initializeCursor(nullptr, 0);
engine->_root = root;
return engine; return engine;
} }

View File

@ -166,12 +166,12 @@ function printUsage () {
function filterTestcaseByOptions (testname, options, whichFilter) function filterTestcaseByOptions (testname, options, whichFilter)
{ {
if ((testname.indexOf("-cluster") !== -1) && (options.cluster === false)) { if ((testname.indexOf("-cluster") !== -1) && (options.cluster === false)) {
whichFilter.filter = 'cluster'; whichFilter.filter = 'noncluster';
return false; return false;
} }
if (testname.indexOf("-noncluster") !== -1 && (options.cluster === true)) { if (testname.indexOf("-noncluster") !== -1 && (options.cluster === true)) {
whichFilter.filter = 'noncluster'; whichFilter.filter = 'cluster';
return false; return false;
} }