mirror of https://gitee.com/bigwinds/arangodb
fix crashes and assertion failures
This commit is contained in:
parent
4387fabacf
commit
557f6cbcff
|
@ -1549,7 +1549,7 @@ OperationResult transaction::Methods::insert(std::string const& collectionName,
|
||||||
if (_state->isCoordinator()) {
|
if (_state->isCoordinator()) {
|
||||||
return insertCoordinator(collectionName, value, optionsCopy);
|
return insertCoordinator(collectionName, value, optionsCopy);
|
||||||
}
|
}
|
||||||
if (_state->isDBServer() && !optionsCopy.isSynchronousReplicationFrom.empty()) {
|
if (_state->isDBServer()) {
|
||||||
optionsCopy.silent = false;
|
optionsCopy.silent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1670,25 +1670,27 @@ OperationResult transaction::Methods::insertLocal(
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.silent) {
|
|
||||||
|
|
||||||
|
if (!options.silent || _state->isDBServer()) {
|
||||||
TRI_ASSERT(!documentResult.empty());
|
TRI_ASSERT(!documentResult.empty());
|
||||||
|
|
||||||
StringRef keyString(transaction::helpers::extractKeyFromDocument(
|
StringRef keyString(transaction::helpers::extractKeyFromDocument(
|
||||||
VPackSlice(documentResult.vpack())));
|
VPackSlice(documentResult.vpack())));
|
||||||
|
|
||||||
bool showReplaced = false;
|
bool showReplaced = false;
|
||||||
if(options.returnOld && previousRevisionId){
|
if(options.returnOld && previousRevisionId){
|
||||||
showReplaced = true;
|
showReplaced = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(showReplaced){
|
if(showReplaced){
|
||||||
TRI_ASSERT(!previousDocumentResult.empty());
|
TRI_ASSERT(!previousDocumentResult.empty());
|
||||||
}
|
}
|
||||||
|
|
||||||
buildDocumentIdentity(collection, resultBuilder
|
buildDocumentIdentity(collection, resultBuilder
|
||||||
,cid, keyString, revisionId ,previousRevisionId
|
,cid, keyString, revisionId ,previousRevisionId
|
||||||
,showReplaced ? &previousDocumentResult : nullptr
|
,showReplaced ? &previousDocumentResult : nullptr
|
||||||
,options.returnNew ? &documentResult : nullptr);
|
,options.returnNew ? &documentResult : nullptr);
|
||||||
}
|
}
|
||||||
return Result();
|
return Result();
|
||||||
};
|
};
|
||||||
|
@ -1732,8 +1734,7 @@ OperationResult transaction::Methods::insertLocal(
|
||||||
std::string path =
|
std::string path =
|
||||||
"/_db/" + arangodb::basics::StringUtils::urlEncode(vocbase().name()) +
|
"/_db/" + arangodb::basics::StringUtils::urlEncode(vocbase().name()) +
|
||||||
"/_api/document/" + arangodb::basics::StringUtils::urlEncode(collection->name()) +
|
"/_api/document/" + arangodb::basics::StringUtils::urlEncode(collection->name()) +
|
||||||
"?isRestore=true&isSynchronousReplication=" + ServerState::instance()->getId() +
|
"?isRestore=true&isSynchronousReplication=" + ServerState::instance()->getId();
|
||||||
"&" + StaticStrings::SilentString + "=true" +
|
|
||||||
"&" + StaticStrings::OverWrite + "=" + (options.overwrite ? "true" : "false");
|
"&" + StaticStrings::OverWrite + "=" + (options.overwrite ? "true" : "false");
|
||||||
|
|
||||||
VPackBuilder payload;
|
VPackBuilder payload;
|
||||||
|
@ -1856,7 +1857,7 @@ OperationResult transaction::Methods::update(std::string const& collectionName,
|
||||||
if (_state->isCoordinator()) {
|
if (_state->isCoordinator()) {
|
||||||
return updateCoordinator(collectionName, newValue, optionsCopy);
|
return updateCoordinator(collectionName, newValue, optionsCopy);
|
||||||
}
|
}
|
||||||
if (_state->isDBServer() && !optionsCopy.isSynchronousReplicationFrom.empty()) {
|
if (_state->isDBServer()) {
|
||||||
optionsCopy.silent = false;
|
optionsCopy.silent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1917,7 +1918,7 @@ OperationResult transaction::Methods::replace(std::string const& collectionName,
|
||||||
if (_state->isCoordinator()) {
|
if (_state->isCoordinator()) {
|
||||||
return replaceCoordinator(collectionName, newValue, optionsCopy);
|
return replaceCoordinator(collectionName, newValue, optionsCopy);
|
||||||
}
|
}
|
||||||
if (_state->isDBServer() && !optionsCopy.isSynchronousReplicationFrom.empty()) {
|
if (_state->isDBServer()) {
|
||||||
optionsCopy.silent = false;
|
optionsCopy.silent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2042,7 +2043,7 @@ OperationResult transaction::Methods::modifyLocal(
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!options.silent) {
|
if (!options.silent || _state->isDBServer()) {
|
||||||
TRI_ASSERT(!previous.empty());
|
TRI_ASSERT(!previous.empty());
|
||||||
TRI_ASSERT(!result.empty());
|
TRI_ASSERT(!result.empty());
|
||||||
StringRef key(newVal.get(StaticStrings::KeyString));
|
StringRef key(newVal.get(StaticStrings::KeyString));
|
||||||
|
@ -2106,7 +2107,7 @@ OperationResult transaction::Methods::modifyLocal(
|
||||||
"/_api/document/" +
|
"/_api/document/" +
|
||||||
arangodb::basics::StringUtils::urlEncode(collection->name()) +
|
arangodb::basics::StringUtils::urlEncode(collection->name()) +
|
||||||
"?isRestore=true&isSynchronousReplication=" +
|
"?isRestore=true&isSynchronousReplication=" +
|
||||||
ServerState::instance()->getId() + "&" + StaticStrings::SilentString + "=true";
|
ServerState::instance()->getId();
|
||||||
|
|
||||||
VPackBuilder payload;
|
VPackBuilder payload;
|
||||||
|
|
||||||
|
@ -2229,7 +2230,7 @@ OperationResult transaction::Methods::remove(std::string const& collectionName,
|
||||||
if (_state->isCoordinator()) {
|
if (_state->isCoordinator()) {
|
||||||
return removeCoordinator(collectionName, value, optionsCopy);
|
return removeCoordinator(collectionName, value, optionsCopy);
|
||||||
}
|
}
|
||||||
if (_state->isDBServer() && !optionsCopy.isSynchronousReplicationFrom.empty()) {
|
if (_state->isDBServer()) {
|
||||||
optionsCopy.silent = false;
|
optionsCopy.silent = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2343,7 +2344,7 @@ OperationResult transaction::Methods::removeLocal(
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(!previous.empty());
|
TRI_ASSERT(!previous.empty());
|
||||||
if (!options.silent) {
|
if (!options.silent || _state->isDBServer()) {
|
||||||
buildDocumentIdentity(collection, resultBuilder, cid, key, actualRevision,
|
buildDocumentIdentity(collection, resultBuilder, cid, key, actualRevision,
|
||||||
0, options.returnOld ? &previous : nullptr, nullptr);
|
0, options.returnOld ? &previous : nullptr, nullptr);
|
||||||
}
|
}
|
||||||
|
@ -2397,7 +2398,7 @@ OperationResult transaction::Methods::removeLocal(
|
||||||
"/_api/document/" +
|
"/_api/document/" +
|
||||||
arangodb::basics::StringUtils::urlEncode(collection->name()) +
|
arangodb::basics::StringUtils::urlEncode(collection->name()) +
|
||||||
"?isRestore=true&isSynchronousReplication=" +
|
"?isRestore=true&isSynchronousReplication=" +
|
||||||
ServerState::instance()->getId() + "&" + StaticStrings::SilentString + "=true";
|
ServerState::instance()->getId();
|
||||||
|
|
||||||
VPackBuilder payload;
|
VPackBuilder payload;
|
||||||
|
|
||||||
|
@ -2668,7 +2669,10 @@ OperationResult transaction::Methods::truncateLocal(
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t nrDone = 0;
|
size_t nrDone = 0;
|
||||||
size_t nrGood = cc->performRequests(requests, 120.0,
|
// TODO: is TRX_FOLLOWER_TIMEOUT actually appropriate here? truncate
|
||||||
|
// can be a much more expensive operation than a single document
|
||||||
|
// insert/update/remove...
|
||||||
|
size_t nrGood = cc->performRequests(requests, TRX_FOLLOWER_TIMEOUT,
|
||||||
nrDone, Logger::REPLICATION, false);
|
nrDone, Logger::REPLICATION, false);
|
||||||
if (nrGood < followers->size()) {
|
if (nrGood < followers->size()) {
|
||||||
// If any would-be-follower refused to follow there must be a
|
// If any would-be-follower refused to follow there must be a
|
||||||
|
|
|
@ -128,6 +128,8 @@ class Methods {
|
||||||
using VPackBuilder = arangodb::velocypack::Builder;
|
using VPackBuilder = arangodb::velocypack::Builder;
|
||||||
using VPackSlice = arangodb::velocypack::Slice;
|
using VPackSlice = arangodb::velocypack::Slice;
|
||||||
|
|
||||||
|
double const TRX_FOLLOWER_TIMEOUT = 3.0;
|
||||||
|
|
||||||
/// @brief transaction::Methods
|
/// @brief transaction::Methods
|
||||||
private:
|
private:
|
||||||
Methods() = delete;
|
Methods() = delete;
|
||||||
|
|
Loading…
Reference in New Issue