Always plan Synchronize if the plan needs it

Reviewers: florijan, msantl

Reviewed By: florijan

Subscribers: pullbot

Differential Revision: https://phabricator.memgraph.io/D1241
This commit is contained in:
Teon Banek 2018-02-26 11:08:39 +01:00
parent 7a39693ad9
commit a44d9a0fac
2 changed files with 31 additions and 3 deletions

View File

@ -771,9 +771,9 @@ DistributedPlan MakeDistributedPlan(const LogicalOperator &original_plan,
worker_plan, pull_id,
worker_plan->OutputSymbols(distributed_plan.symbol_table));
}
} else if (distributed_plan.worker_plans.empty() &&
planner.NeedsSynchronize()) {
// If the plan performs writes, we still need to Synchronize.
} else if (planner.NeedsSynchronize()) {
// If the plan performs writes on master, we still need to Synchronize, even
// though we don't split the plan.
distributed_plan.master_plan = std::make_unique<Synchronize>(
std::move(distributed_plan.master_plan), nullptr, false);
}

View File

@ -2204,4 +2204,32 @@ TYPED_TEST(TestPlanner, DistributedMatchCreateReturn) {
MakeCheckers(ExpectScanAll(), ExpectCreateNode()));
CheckDistributedPlan(planner.plan(), symbol_table, expected);
}
TYPED_TEST(TestPlanner, DistributedCartesianCreate) {
// Test MATCH (a), (b) CREATE (a)-[e:r]->(b)
AstTreeStorage storage;
database::Master db;
database::GraphDbAccessor dba(db);
auto relationship = dba.EdgeType("r");
auto *node_a = NODE("a");
auto *node_b = NODE("b");
QUERY(SINGLE_QUERY(
MATCH(PATTERN(node_a), PATTERN(node_b)),
CREATE(PATTERN(NODE("a"), EDGE("e", Direction::OUT, {relationship}),
NODE("b")))));
auto symbol_table = MakeSymbolTable(*storage.query());
auto left_cart =
MakeCheckers(ExpectScanAll(),
ExpectPullRemote({symbol_table.at(*node_a->identifier_)}));
auto right_cart =
MakeCheckers(ExpectScanAll(),
ExpectPullRemote({symbol_table.at(*node_b->identifier_)}));
auto expected = ExpectDistributed(
MakeCheckers(ExpectCartesian(std::move(left_cart), std::move(right_cart)),
ExpectCreateExpand(), ExpectSynchronize(false)),
MakeCheckers(ExpectScanAll()), MakeCheckers(ExpectScanAll()));
auto planner = MakePlanner<TypeParam>(db, storage, symbol_table);
CheckDistributedPlan(planner.plan(), symbol_table, expected);
}
} // namespace