diff --git a/src/storage/v2/indices.cpp b/src/storage/v2/indices.cpp index eab45120a..78e3fc408 100644 --- a/src/storage/v2/indices.cpp +++ b/src/storage/v2/indices.cpp @@ -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); diff --git a/tests/unit/storage_v2_indices.cpp b/tests/unit/storage_v2_indices.cpp index a8f964d91..d601d60de 100644 --- a/tests/unit/storage_v2_indices.cpp +++ b/tests/unit/storage_v2_indices.cpp @@ -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();