mirror of https://gitee.com/bigwinds/arangodb
bug-fix-3.3/double-modification-bug (#5981)
This commit is contained in:
parent
e266efdf96
commit
7c63c0e2fc
|
@ -3037,7 +3037,7 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
|||
for (ExecutionNode* subqueryNode : subqueryNodes) {
|
||||
SubqueryNode* snode = nullptr;
|
||||
ExecutionNode* root = nullptr; //only used for asserts
|
||||
bool hasFound = false;
|
||||
bool reachedEnd = false;
|
||||
if (subqueryNode == plan->root()) {
|
||||
snode = nullptr;
|
||||
root = plan->root();
|
||||
|
@ -3052,20 +3052,21 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
|||
// loop until we find a modification node or the end of the plan
|
||||
auto nodeType = node->getType();
|
||||
|
||||
while (node != nullptr) {
|
||||
// check if there is a node type that needs distribution
|
||||
nodeType = node->getType();
|
||||
if (nodeType == ExecutionNode::INSERT ||
|
||||
nodeType == ExecutionNode::REMOVE ||
|
||||
nodeType == ExecutionNode::UPDATE ||
|
||||
nodeType == ExecutionNode::REPLACE ||
|
||||
nodeType == ExecutionNode::UPSERT) {
|
||||
// found a node!
|
||||
hasFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// there is nothing above us
|
||||
if (!node->hasDependency()) {
|
||||
// reached the end
|
||||
reachedEnd = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3073,8 +3074,8 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
|||
node = node->getFirstDependency();
|
||||
}
|
||||
|
||||
if (!hasFound){
|
||||
continue;
|
||||
if (reachedEnd){
|
||||
break;
|
||||
}
|
||||
|
||||
TRI_ASSERT(node != nullptr);
|
||||
|
@ -3093,8 +3094,6 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
|||
}
|
||||
|
||||
// when we get here, we have found a matching data-modification node!
|
||||
auto const nodeType = node->getType();
|
||||
|
||||
TRI_ASSERT(nodeType == ExecutionNode::INSERT ||
|
||||
nodeType == ExecutionNode::REMOVE ||
|
||||
nodeType == ExecutionNode::UPDATE ||
|
||||
|
@ -3110,7 +3109,7 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
|||
ci->getCollection(collection->vocbase->name(), collection->name);
|
||||
// Throws if collection is not found!
|
||||
if (collInfo->isSmart() && collInfo->type() == TRI_COL_TYPE_EDGE) {
|
||||
distributeInClusterRuleSmartEdgeCollection(
|
||||
node = distributeInClusterRuleSmartEdgeCollection(
|
||||
plan.get(), snode, node, originalParent, wasModified);
|
||||
continue;
|
||||
}
|
||||
|
@ -3121,6 +3120,7 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
|||
nodeType == ExecutionNode::UPDATE) {
|
||||
if (!defaultSharding) {
|
||||
// We have to use a ScatterNode.
|
||||
node = node->getFirstDependency();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -3251,6 +3251,8 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
|||
}
|
||||
}
|
||||
wasModified = true;
|
||||
node = distNode;
|
||||
}
|
||||
} // for end nodes in plan
|
||||
opt->addPlan(std::move(plan), rule, wasModified);
|
||||
}
|
||||
|
@ -3273,7 +3275,6 @@ void arangodb::aql::collectInClusterRule(Optimizer* opt,
|
|||
|
||||
// found a node we need to replace in the plan
|
||||
|
||||
auto const& parents = node->getParents();
|
||||
auto const& deps = node->getDependencies();
|
||||
TRI_ASSERT(deps.size() == 1);
|
||||
|
||||
|
|
|
@ -129,7 +129,7 @@ void distributeInClusterRule(Optimizer*, std::unique_ptr<ExecutionPlan>,
|
|||
OptimizerRule const*);
|
||||
|
||||
#ifdef USE_ENTERPRISE
|
||||
void distributeInClusterRuleSmartEdgeCollection(
|
||||
ExecutionNode* distributeInClusterRuleSmartEdgeCollection(
|
||||
ExecutionPlan*,
|
||||
SubqueryNode* snode,
|
||||
ExecutionNode* node,
|
||||
|
|
|
@ -511,6 +511,27 @@ function ahuacatlInsertSuite () {
|
|||
c3 = null;
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test insert
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
testInsertDouble : function () {
|
||||
c1.truncate();
|
||||
c2.truncate();
|
||||
var expected = { writesExecuted: 0, writesIgnored: 0 };
|
||||
const query = `LET dog = {name:'ulf'}
|
||||
LET pussy = {name : 'uschi'}
|
||||
INSERT dog IN @@hunde
|
||||
INSERT pussy IN @@kartzen
|
||||
RETURN $NEW`;
|
||||
const bind = { "@hunde" : cn1, "@kartzen" : cn2 };
|
||||
const options = {optimizer : { rules : ["+restrict-to-single-shard","-optimize-cluster-single-document-operations", "-remove-unnecessary-remote-scatter"] } };
|
||||
|
||||
db._query(query, bind, options);
|
||||
assertEqual(1, c1.count());
|
||||
assertEqual(1, c2.count());
|
||||
},
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test insert
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Reference in New Issue