mirror of https://gitee.com/bigwinds/arangodb
fix random willi bug (#10197)
This commit is contained in:
parent
bf187f4b50
commit
58fb6fd36b
|
@ -176,7 +176,7 @@ bool RestDocumentHandler::insertDocument() {
|
|||
|
||||
Result res = trx->begin();
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -187,12 +187,12 @@ bool RestDocumentHandler::insertDocument() {
|
|||
// result stays valid!
|
||||
res = trx->finish(result.result);
|
||||
if (result.fail()) {
|
||||
generateTransactionError(result);
|
||||
generateTransactionError(collectionName, result, "");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -277,7 +277,7 @@ bool RestDocumentHandler::readSingleDocument(bool generateBody) {
|
|||
Result res = trx->begin();
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collection, res, "");
|
||||
generateTransactionError(collection, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -292,13 +292,13 @@ bool RestDocumentHandler::readSingleDocument(bool generateBody) {
|
|||
} else if (ifRid != 0 && result.is(TRI_ERROR_ARANGO_CONFLICT)) {
|
||||
generatePreconditionFailed(result.slice());
|
||||
} else {
|
||||
generateTransactionError(collection, res, key);
|
||||
generateTransactionError(collection, OperationResult(std::move(res)), key);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collection, res, key);
|
||||
generateTransactionError(collection, OperationResult(std::move(res)), key);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -463,8 +463,9 @@ bool RestDocumentHandler::modifyDocument(bool isPatch) {
|
|||
// ...........................................................................
|
||||
|
||||
Result res = trx->begin();
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -486,12 +487,12 @@ bool RestDocumentHandler::modifyDocument(bool isPatch) {
|
|||
// ...........................................................................
|
||||
|
||||
if (result.fail()) {
|
||||
generateTransactionError(result);
|
||||
generateTransactionError(collectionName, result, key);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, key, 0);
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), key);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -586,7 +587,7 @@ bool RestDocumentHandler::removeDocument() {
|
|||
Result res = trx->begin();
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -596,12 +597,12 @@ bool RestDocumentHandler::removeDocument() {
|
|||
res = trx->finish(result.result);
|
||||
|
||||
if (result.fail()) {
|
||||
generateTransactionError(result);
|
||||
generateTransactionError(collectionName, result, key);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, key);
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), key);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -639,7 +640,7 @@ bool RestDocumentHandler::readManyDocuments() {
|
|||
Result res = trx->begin();
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -651,12 +652,12 @@ bool RestDocumentHandler::readManyDocuments() {
|
|||
res = trx->finish(result.result);
|
||||
|
||||
if (result.fail()) {
|
||||
generateTransactionError(result);
|
||||
generateTransactionError(collectionName, result, "");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -219,8 +219,7 @@ bool RestEdgesHandler::readEdges() {
|
|||
Result res = trx->begin();
|
||||
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -265,7 +264,7 @@ bool RestEdgesHandler::readEdges() {
|
|||
// name for error reporting:
|
||||
collectionName = trx->resolver()->getCollectionNameCluster(cid);
|
||||
}
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -360,7 +359,7 @@ bool RestEdgesHandler::readEdgesForMultipleVertices() {
|
|||
|
||||
Result res = trx->begin();
|
||||
if (!res.ok()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -406,7 +405,7 @@ bool RestEdgesHandler::readEdgesForMultipleVertices() {
|
|||
// name for error reporting:
|
||||
collectionName = trx->resolver()->getCollectionNameCluster(cid);
|
||||
}
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ void RestGraphHandler::vertexActionRead(Graph& graph, std::string const& collect
|
|||
} else if (maybeRev && result.is(TRI_ERROR_ARANGO_CONFLICT)) {
|
||||
generatePreconditionFailed(result.slice());
|
||||
} else {
|
||||
generateTransactionError(collectionName, result.result, key);
|
||||
generateTransactionError(collectionName, result, key);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -358,7 +358,7 @@ bool RestImportHandler::createFromJson(std::string const& type) {
|
|||
Result res = trx.begin();
|
||||
|
||||
if (res.fail()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -514,7 +514,7 @@ bool RestImportHandler::createFromJson(std::string const& type) {
|
|||
res = trx.finish(res);
|
||||
|
||||
if (res.fail()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
} else {
|
||||
generateDocumentsCreated(result);
|
||||
}
|
||||
|
@ -564,7 +564,7 @@ bool RestImportHandler::createFromVPack(std::string const& type) {
|
|||
Result res = trx.begin();
|
||||
|
||||
if (res.fail()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -619,7 +619,7 @@ bool RestImportHandler::createFromVPack(std::string const& type) {
|
|||
res = trx.finish(res);
|
||||
|
||||
if (res.fail()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
} else {
|
||||
generateDocumentsCreated(result);
|
||||
}
|
||||
|
@ -746,7 +746,7 @@ bool RestImportHandler::createFromKeyValueList() {
|
|||
Result res = trx.begin();
|
||||
|
||||
if (res.fail()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -848,7 +848,7 @@ bool RestImportHandler::createFromKeyValueList() {
|
|||
res = trx.finish(res);
|
||||
|
||||
if (res.fail()) {
|
||||
generateTransactionError(collectionName, res, "");
|
||||
generateTransactionError(collectionName, OperationResult(std::move(res)), "");
|
||||
} else {
|
||||
generateDocumentsCreated(result);
|
||||
}
|
||||
|
|
|
@ -376,6 +376,7 @@ void RestVocbaseBaseHandler::generatePreconditionFailed(VPackSlice const& slice)
|
|||
VPackValue(static_cast<int32_t>(rest::ResponseCode::PRECONDITION_FAILED)));
|
||||
builder.add(StaticStrings::ErrorNum, VPackValue(TRI_ERROR_ARANGO_CONFLICT));
|
||||
builder.add(StaticStrings::ErrorMessage, VPackValue("precondition failed"));
|
||||
|
||||
if (slice.isObject()) {
|
||||
builder.add(StaticStrings::IdString, slice.get(StaticStrings::IdString));
|
||||
builder.add(StaticStrings::KeyString, slice.get(StaticStrings::KeyString));
|
||||
|
@ -482,7 +483,7 @@ void RestVocbaseBaseHandler::generateTransactionError(std::string const& collect
|
|||
return;
|
||||
|
||||
case TRI_ERROR_ARANGO_CONFLICT:
|
||||
if (result.buffer != nullptr) {
|
||||
if (result.buffer != nullptr && !result.slice().isNone()) {
|
||||
// This case happens if we come via the generateTransactionError that
|
||||
// has a proper OperationResult with a slice:
|
||||
generatePreconditionFailed(result.slice());
|
||||
|
|
|
@ -199,13 +199,6 @@ class RestVocbaseBaseHandler : public RestBaseHandler {
|
|||
OperationResult const& result,
|
||||
std::string const& key, TRI_voc_rid_t = 0);
|
||||
|
||||
/// @brief generate an error message for a transaction error
|
||||
void generateTransactionError(std::string const& collectionName,
|
||||
Result const& res,
|
||||
std::string const& key, TRI_voc_rid_t rid = 0) {
|
||||
generateTransactionError(collectionName, OperationResult(res), key, rid);
|
||||
}
|
||||
|
||||
/// @brief generate an error message for a transaction error
|
||||
void generateTransactionError(OperationResult const& result) {
|
||||
generateTransactionError("", result, "", 0);
|
||||
|
|
|
@ -1788,7 +1788,7 @@ OperationResult transaction::Methods::insertLocal(std::string const& collectionN
|
|||
ManagedDocumentResult docResult;
|
||||
ManagedDocumentResult prevDocResult; // return OLD (with override option)
|
||||
|
||||
auto workForOneDocument = [&](VPackSlice const value) -> Result {
|
||||
auto workForOneDocument = [&](VPackSlice const value, bool isBabies) -> Result {
|
||||
if (!value.isObject()) {
|
||||
return Result(TRI_ERROR_ARANGO_DOCUMENT_TYPE_INVALID);
|
||||
}
|
||||
|
@ -1826,7 +1826,13 @@ OperationResult transaction::Methods::insertLocal(std::string const& collectionN
|
|||
|
||||
if (res.fail()) {
|
||||
// Error reporting in the babies case is done outside of here,
|
||||
// in the single document case no body needs to be created at all.
|
||||
if (res.is(TRI_ERROR_ARANGO_CONFLICT) && !isBabies) {
|
||||
TRI_ASSERT(prevDocResult.revisionId() != 0);
|
||||
|
||||
arangodb::velocypack::StringRef key = value.get(StaticStrings::KeyString).stringRef();
|
||||
buildDocumentIdentity(collection, resultBuilder, cid, key, prevDocResult.revisionId(),
|
||||
0, nullptr, nullptr);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -1857,7 +1863,7 @@ OperationResult transaction::Methods::insertLocal(std::string const& collectionN
|
|||
if (value.isArray()) {
|
||||
VPackArrayBuilder b(&resultBuilder);
|
||||
for (auto const& s : VPackArrayIterator(value)) {
|
||||
res = workForOneDocument(s);
|
||||
res = workForOneDocument(s, true);
|
||||
if (res.fail()) {
|
||||
createBabiesError(resultBuilder, countErrorCodes, res);
|
||||
}
|
||||
|
@ -1865,7 +1871,7 @@ OperationResult transaction::Methods::insertLocal(std::string const& collectionN
|
|||
// With babies the reporting is handled in the body of the result
|
||||
res = Result(TRI_ERROR_NO_ERROR);
|
||||
} else {
|
||||
res = workForOneDocument(value);
|
||||
res = workForOneDocument(value, false);
|
||||
}
|
||||
if (res.ok() && replicationType == ReplicationType::LEADER) {
|
||||
TRI_ASSERT(collection != nullptr);
|
||||
|
|
Loading…
Reference in New Issue