Ignore commited transactions
This commit is contained in:
parent
db13ee96b6
commit
6de683d7f9
@ -1179,7 +1179,10 @@ std::map<uint64_t, Transaction> Shard::CollectTransactions(const std::set<uint64
|
|||||||
EdgeContainer &cloned_edges) {
|
EdgeContainer &cloned_edges) {
|
||||||
std::map<uint64_t, Transaction> transactions;
|
std::map<uint64_t, Transaction> transactions;
|
||||||
for (const auto commit_start : collected_transactions_start_id) {
|
for (const auto commit_start : collected_transactions_start_id) {
|
||||||
transactions.insert({commit_start, start_logical_id_to_transaction_.at(commit_start)->Clone()});
|
// If it does not contain then the transaction has commited, and we ignore it
|
||||||
|
if (start_logical_id_to_transaction_.contains(commit_start)) {
|
||||||
|
transactions.insert({commit_start, start_logical_id_to_transaction_[commit_start]->Clone()});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// It is necessary to clone all the transactions first so we have new addresses
|
// It is necessary to clone all the transactions first so we have new addresses
|
||||||
// for deltas, before doing alignment of deltas and prev_ptr
|
// for deltas, before doing alignment of deltas and prev_ptr
|
||||||
|
@ -87,7 +87,7 @@ TEST_F(ShardSplitTest, TestBasicSplitVerticesAndEdges) {
|
|||||||
EXPECT_EQ(splitted_data.transactions.size(), 0);
|
EXPECT_EQ(splitted_data.transactions.size(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ShardSplitTest, TestBasicSplit) {
|
TEST_F(ShardSplitTest, TestBasicSplitBeforeCommit) {
|
||||||
auto acc = storage.Access(GetNextHlc());
|
auto acc = storage.Access(GetNextHlc());
|
||||||
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(1)}, {}).HasError());
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(1)}, {}).HasError());
|
||||||
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(2)}, {}).HasError());
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(2)}, {}).HasError());
|
||||||
@ -112,4 +112,31 @@ TEST_F(ShardSplitTest, TestBasicSplit) {
|
|||||||
EXPECT_EQ(splitted_data.transactions.size(), 1);
|
EXPECT_EQ(splitted_data.transactions.size(), 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(ShardSplitTest, TestBasicSplitAfterCommit) {
|
||||||
|
auto acc = storage.Access(GetNextHlc());
|
||||||
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(1)}, {}).HasError());
|
||||||
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(2)}, {}).HasError());
|
||||||
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(3)}, {}).HasError());
|
||||||
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(4)}, {}).HasError());
|
||||||
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(5)}, {}).HasError());
|
||||||
|
EXPECT_FALSE(acc.CreateVertexAndValidate({}, {PropertyValue(6)}, {}).HasError());
|
||||||
|
|
||||||
|
EXPECT_FALSE(acc.CreateEdge(VertexId{primary_label, PrimaryKey{PropertyValue(1)}},
|
||||||
|
VertexId{primary_label, PrimaryKey{PropertyValue(2)}}, edge_type_id, Gid::FromUint(0))
|
||||||
|
.HasError());
|
||||||
|
EXPECT_FALSE(acc.CreateEdge(VertexId{primary_label, PrimaryKey{PropertyValue(1)}},
|
||||||
|
VertexId{primary_label, PrimaryKey{PropertyValue(5)}}, edge_type_id, Gid::FromUint(1))
|
||||||
|
.HasError());
|
||||||
|
EXPECT_FALSE(acc.CreateEdge(VertexId{primary_label, PrimaryKey{PropertyValue(4)}},
|
||||||
|
VertexId{primary_label, PrimaryKey{PropertyValue(6)}}, edge_type_id, Gid::FromUint(2))
|
||||||
|
.HasError());
|
||||||
|
|
||||||
|
acc.Commit(GetNextHlc());
|
||||||
|
|
||||||
|
auto splitted_data = storage.PerformSplit({PropertyValue(4)});
|
||||||
|
EXPECT_EQ(splitted_data.vertices.size(), 3);
|
||||||
|
EXPECT_EQ(splitted_data.edges->size(), 2);
|
||||||
|
EXPECT_EQ(splitted_data.transactions.size(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace memgraph::storage::v3::tests
|
} // namespace memgraph::storage::v3::tests
|
||||||
|
Loading…
Reference in New Issue
Block a user