1
0
Fork 0

Improved baby errors in cluster

This commit is contained in:
Michael Hackstein 2016-04-15 14:48:44 +02:00
parent 0e2d31f633
commit 20733a81ae
2 changed files with 30 additions and 9 deletions

View File

@ -1129,6 +1129,9 @@ int deleteDocumentOnCoordinator(
// If we get here we get exactly one result for every shard.
TRI_ASSERT(allResults.size() == shardList->size());
mergeResultsAllShards(allResults, resultBody, errorCounter, shardList->size());
responseCode =
(options.waitForSync ? GeneralResponse::ResponseCode::OK
: GeneralResponse::ResponseCode::ACCEPTED);
return TRI_ERROR_NO_ERROR;
}
@ -2042,7 +2045,9 @@ int modifyDocumentOnCoordinator(
// Local data structores are automatically freed
return error;
}
TRI_ASSERT(res.answer_code == arangodb::GeneralResponse::ResponseCode::OK);
TRI_ASSERT(res.answer_code == arangodb::GeneralResponse::ResponseCode::OK ||
res.answer_code ==
arangodb::GeneralResponse::ResponseCode::ACCEPTED);
TRI_ASSERT(res.answer != nullptr);
allResults.emplace_back(res.answer->toVelocyPack(&VPackOptions::Defaults));
extractErrorCodes(res, errorCounter, false);
@ -2050,6 +2055,9 @@ int modifyDocumentOnCoordinator(
// If we get here we get exactly one result for every shard.
TRI_ASSERT(allResults.size() == shardList->size());
mergeResultsAllShards(allResults, resultBody, errorCounter, shardList->size());
responseCode =
(options.waitForSync ? GeneralResponse::ResponseCode::OK
: GeneralResponse::ResponseCode::ACCEPTED);
return TRI_ERROR_NO_ERROR;
}

View File

@ -29,6 +29,7 @@ var ERRORS = arangodb.errors;
var db = arangodb.db;
var internal = require("internal");
var wait = internal.wait;
var cluster = require("@arangodb/cluster");
////////////////////////////////////////////////////////////////////////////////
/// @brief test suite: babies for documents
@ -763,14 +764,26 @@ function CollectionDocumentSuiteBabies() {
}
// Replace
docs = collection.replace([x, x, x], [{}, {}, {}]);
assertEqual(docs.length, expectedLength);
for (var i = 0; i < expectedLength; ++i) {
assertEqual(docs[i].error, true);
if (typeof x === "string") {
assertEqual(docs[i].errorNum, ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code);
} else {
assertEqual(docs[i].errorNum, ERRORS.ERROR_ARANGO_DOCUMENT_HANDLE_BAD.code);
if (typeof x === "object" && !Array.isArray(x) &&
cluster.isCoordinator()) {
try {
docs = collection.replace([x, x, x], [{}, {}, {}]);
fail();
} catch (err) {
// In this case the coordinator will directly figure out that no
// keys are given
assertEqual(err.errorNum, ERRORS.ERROR_CLUSTER_NOT_ALL_SHARDING_ATTRIBUTES_GIVEN.code);
}
} else {
docs = collection.replace([x, x, x], [{}, {}, {}]);
assertEqual(docs.length, expectedLength);
for (var i = 0; i < expectedLength; ++i) {
assertEqual(docs[i].error, true);
if (typeof x === "string") {
assertEqual(docs[i].errorNum, ERRORS.ERROR_ARANGO_DOCUMENT_NOT_FOUND.code);
} else {
assertEqual(docs[i].errorNum, ERRORS.ERROR_ARANGO_DOCUMENT_HANDLE_BAD.code);
}
}
}