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) {
|
for (ExecutionNode* subqueryNode : subqueryNodes) {
|
||||||
SubqueryNode* snode = nullptr;
|
SubqueryNode* snode = nullptr;
|
||||||
ExecutionNode* root = nullptr; //only used for asserts
|
ExecutionNode* root = nullptr; //only used for asserts
|
||||||
bool hasFound = false;
|
bool reachedEnd = false;
|
||||||
if (subqueryNode == plan->root()) {
|
if (subqueryNode == plan->root()) {
|
||||||
snode = nullptr;
|
snode = nullptr;
|
||||||
root = plan->root();
|
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
|
// loop until we find a modification node or the end of the plan
|
||||||
auto nodeType = node->getType();
|
auto nodeType = node->getType();
|
||||||
|
|
||||||
|
while (node != nullptr) {
|
||||||
// check if there is a node type that needs distribution
|
// check if there is a node type that needs distribution
|
||||||
|
nodeType = node->getType();
|
||||||
if (nodeType == ExecutionNode::INSERT ||
|
if (nodeType == ExecutionNode::INSERT ||
|
||||||
nodeType == ExecutionNode::REMOVE ||
|
nodeType == ExecutionNode::REMOVE ||
|
||||||
nodeType == ExecutionNode::UPDATE ||
|
nodeType == ExecutionNode::UPDATE ||
|
||||||
nodeType == ExecutionNode::REPLACE ||
|
nodeType == ExecutionNode::REPLACE ||
|
||||||
nodeType == ExecutionNode::UPSERT) {
|
nodeType == ExecutionNode::UPSERT) {
|
||||||
// found a node!
|
// found a node!
|
||||||
hasFound = true;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// there is nothing above us
|
// there is nothing above us
|
||||||
if (!node->hasDependency()) {
|
if (!node->hasDependency()) {
|
||||||
// reached the end
|
reachedEnd = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3073,8 +3074,8 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
||||||
node = node->getFirstDependency();
|
node = node->getFirstDependency();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasFound){
|
if (reachedEnd){
|
||||||
continue;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
TRI_ASSERT(node != nullptr);
|
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!
|
// when we get here, we have found a matching data-modification node!
|
||||||
auto const nodeType = node->getType();
|
|
||||||
|
|
||||||
TRI_ASSERT(nodeType == ExecutionNode::INSERT ||
|
TRI_ASSERT(nodeType == ExecutionNode::INSERT ||
|
||||||
nodeType == ExecutionNode::REMOVE ||
|
nodeType == ExecutionNode::REMOVE ||
|
||||||
nodeType == ExecutionNode::UPDATE ||
|
nodeType == ExecutionNode::UPDATE ||
|
||||||
|
@ -3110,7 +3109,7 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
||||||
ci->getCollection(collection->vocbase->name(), collection->name);
|
ci->getCollection(collection->vocbase->name(), collection->name);
|
||||||
// Throws if collection is not found!
|
// Throws if collection is not found!
|
||||||
if (collInfo->isSmart() && collInfo->type() == TRI_COL_TYPE_EDGE) {
|
if (collInfo->isSmart() && collInfo->type() == TRI_COL_TYPE_EDGE) {
|
||||||
distributeInClusterRuleSmartEdgeCollection(
|
node = distributeInClusterRuleSmartEdgeCollection(
|
||||||
plan.get(), snode, node, originalParent, wasModified);
|
plan.get(), snode, node, originalParent, wasModified);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -3121,6 +3120,7 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
||||||
nodeType == ExecutionNode::UPDATE) {
|
nodeType == ExecutionNode::UPDATE) {
|
||||||
if (!defaultSharding) {
|
if (!defaultSharding) {
|
||||||
// We have to use a ScatterNode.
|
// We have to use a ScatterNode.
|
||||||
|
node = node->getFirstDependency();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3251,6 +3251,8 @@ void arangodb::aql::distributeInClusterRule(Optimizer* opt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
wasModified = true;
|
wasModified = true;
|
||||||
|
node = distNode;
|
||||||
|
}
|
||||||
} // for end nodes in plan
|
} // for end nodes in plan
|
||||||
opt->addPlan(std::move(plan), rule, wasModified);
|
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
|
// found a node we need to replace in the plan
|
||||||
|
|
||||||
auto const& parents = node->getParents();
|
|
||||||
auto const& deps = node->getDependencies();
|
auto const& deps = node->getDependencies();
|
||||||
TRI_ASSERT(deps.size() == 1);
|
TRI_ASSERT(deps.size() == 1);
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,7 @@ void distributeInClusterRule(Optimizer*, std::unique_ptr<ExecutionPlan>,
|
||||||
OptimizerRule const*);
|
OptimizerRule const*);
|
||||||
|
|
||||||
#ifdef USE_ENTERPRISE
|
#ifdef USE_ENTERPRISE
|
||||||
void distributeInClusterRuleSmartEdgeCollection(
|
ExecutionNode* distributeInClusterRuleSmartEdgeCollection(
|
||||||
ExecutionPlan*,
|
ExecutionPlan*,
|
||||||
SubqueryNode* snode,
|
SubqueryNode* snode,
|
||||||
ExecutionNode* node,
|
ExecutionNode* node,
|
||||||
|
|
|
@ -511,6 +511,27 @@ function ahuacatlInsertSuite () {
|
||||||
c3 = null;
|
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
|
/// @brief test insert
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
Loading…
Reference in New Issue