Skip deleted vertices when building index
Summary: There's a possible race condition where we add a deleted vertex into index and garbage collection removes it from main storage before indices are cleaned-up. Reviewers: mferencevic, teon.banek Reviewed By: mferencevic Subscribers: pullbot Differential Revision: https://phabricator.memgraph.io/D2314
This commit is contained in:
parent
4f93632fb8
commit
21d461e77d
@ -449,7 +449,7 @@ bool LabelPropertyIndex::CreateIndex(
|
||||
}
|
||||
auto acc = it->second.access();
|
||||
for (Vertex &vertex : vertices) {
|
||||
if (!utils::Contains(vertex.labels, label)) {
|
||||
if (vertex.deleted || !utils::Contains(vertex.labels, label)) {
|
||||
continue;
|
||||
}
|
||||
auto it = vertex.properties.find(property);
|
||||
|
@ -149,7 +149,7 @@ TEST_F(IndexTest, LabelIndexDuplicateVersions) {
|
||||
EXPECT_THAT(GetIds(acc.Vertices(label1, View::NEW), View::NEW),
|
||||
UnorderedElementsAre(0, 1, 2, 3, 4));
|
||||
|
||||
acc.Commit();
|
||||
ASSERT_EQ(acc.Commit(), std::nullopt);
|
||||
}
|
||||
|
||||
{
|
||||
@ -194,7 +194,7 @@ TEST_F(IndexTest, LabelIndexTransactionalIsolation) {
|
||||
EXPECT_THAT(GetIds(acc_after.Vertices(label1, View::NEW), View::NEW),
|
||||
IsEmpty());
|
||||
|
||||
acc.Commit();
|
||||
ASSERT_EQ(acc.Commit(), std::nullopt);
|
||||
|
||||
auto acc_after_commit = storage.Access();
|
||||
|
||||
@ -324,7 +324,7 @@ TEST_F(IndexTest, LabelPropertyIndexDuplicateVersions) {
|
||||
EXPECT_THAT(GetIds(acc.Vertices(label1, prop_val, View::NEW), View::NEW),
|
||||
UnorderedElementsAre(0, 1, 2, 3, 4));
|
||||
|
||||
acc.Commit();
|
||||
ASSERT_EQ(acc.Commit(), std::nullopt);
|
||||
}
|
||||
|
||||
{
|
||||
@ -374,7 +374,7 @@ TEST_F(IndexTest, LabelPropertyIndexTransactionalIsolation) {
|
||||
GetIds(acc_after.Vertices(label1, prop_val, View::NEW), View::NEW),
|
||||
IsEmpty());
|
||||
|
||||
acc.Commit();
|
||||
ASSERT_EQ(acc.Commit(), std::nullopt);
|
||||
|
||||
auto acc_after_commit = storage.Access();
|
||||
|
||||
@ -408,7 +408,7 @@ TEST_F(IndexTest, LabelPropertyIndexFiltering) {
|
||||
ASSERT_NO_ERROR(vertex.SetProperty(
|
||||
prop_val, i % 2 ? PropertyValue(i / 2) : PropertyValue(i / 2.0)));
|
||||
}
|
||||
acc.Commit();
|
||||
ASSERT_EQ(acc.Commit(), std::nullopt);
|
||||
}
|
||||
{
|
||||
auto acc = storage.Access();
|
||||
|
Loading…
Reference in New Issue
Block a user