1
0
Fork 0

produce more meaningful error messages

This commit is contained in:
Jan Steemann 2016-08-03 13:36:13 +02:00
parent 2062e84ceb
commit fe87b25ebb
4 changed files with 67 additions and 16 deletions

View File

@ -1076,10 +1076,7 @@ static bool throwExceptionAfterBadSyncRequest(ClusterCommResult* res,
bool isShutdown) {
ENTER_BLOCK
if (res->status == CL_COMM_TIMEOUT) {
std::string errorMessage =
std::string("Timeout in communication with shard '") +
std::string(res->shardID) + std::string("' on cluster node '") +
std::string(res->serverID) + std::string("' failed.");
std::string errorMessage = res->stringifyErrorMessage();
// No reply, we give up:
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_CLUSTER_TIMEOUT, errorMessage);
@ -1087,10 +1084,7 @@ static bool throwExceptionAfterBadSyncRequest(ClusterCommResult* res,
if (res->status == CL_COMM_BACKEND_UNAVAILABLE) {
// there is no result
std::string errorMessage =
std::string("Empty result in communication with shard '") +
std::string(res->shardID) + std::string("' on cluster node '") +
std::string(res->serverID) + std::string("'");
std::string errorMessage = res->stringifyErrorMessage();
THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_CLUSTER_CONNECTION_LOST,
errorMessage);
}

View File

@ -559,10 +559,7 @@ struct CoordinatorInstanciator : public WalkerWorker<ExecutionNode> {
error += "\n";
}
} else {
error += std::string("Communication with shard '") +
std::string(res.shardID) + std::string("' on cluster node '") +
std::string(res.serverID) + std::string("' failed : ") +
res.errorMessage;
error += res.stringifyErrorMessage();
}
}
@ -963,11 +960,10 @@ ExecutionEngine* ExecutionEngine::instantiateFromPlan(
url, "{\"code\": 0}", headers, 120.0);
// Ignore result, we need to try to remove all.
// However, log the incident if we have an errorMessage.
if (res->errorMessage.length() > 0) {
if (!res->errorMessage.empty()) {
std::string msg("while trying to unregister query ");
msg += queryId + std::string("from shard: ") + shardId +
std::string("communication failed: ") + res->errorMessage;
LOG(WARN) << "" << msg;
msg += queryId + ": " + res->stringifyErrorMessage();
LOG(WARN) << msg;
}
} else {
// Remove query from registry:

View File

@ -115,6 +115,61 @@ void ClusterCommResult::setDestination(std::string const& dest,
}
}
}
/// @brief stringify the internal error state
std::string ClusterCommResult::stringifyErrorMessage() const {
// append status string
std::string result(stringifyStatus(status));
if (!serverID.empty()) {
result.append(", cluster node: '");
result.append(serverID);
result.push_back('\'');
}
if (!shardID.empty()) {
result.append(", shard: '");
result.append(shardID);
result.push_back('\'');
}
if (!endpoint.empty()) {
result.append(", endpoint: '");
result.append(endpoint);
result.push_back('\'');
}
if (!errorMessage.empty()) {
result.append(", error: '");
result.append(errorMessage);
result.push_back('\'');
}
return result;
}
/// @brief stringify a cluster comm status
char const* ClusterCommResult::stringifyStatus(ClusterCommOpStatus status) {
switch (status) {
case CL_COMM_SUBMITTED:
return "submitted";
case CL_COMM_SENDING:
return "sending";
case CL_COMM_SENT:
return "sent";
case CL_COMM_TIMEOUT:
return "timeout";
case CL_COMM_RECEIVED:
return "received";
case CL_COMM_ERROR:
return "error";
case CL_COMM_DROPPED:
return "dropped";
case CL_COMM_BACKEND_UNAVAILABLE:
return "backend unavailable";
}
return "unknown";
}
////////////////////////////////////////////////////////////////////////////////
/// @brief ClusterComm constructor

View File

@ -212,6 +212,12 @@ struct ClusterCommResult {
//////////////////////////////////////////////////////////////////////////////
void setDestination(std::string const& dest, bool logConnectionErrors);
/// @brief stringify the internal error state
std::string stringifyErrorMessage() const;
/// @brief stringify a cluster comm status
static char const* stringifyStatus(ClusterCommOpStatus status);
};
////////////////////////////////////////////////////////////////////////////////