From e4a3ae6f0528fe3a8a7d5f7a6bf75747321bb460 Mon Sep 17 00:00:00 2001 From: Doodle <13706157+critical27@users.noreply.github.com> Date: Mon, 25 Oct 2021 12:51:13 +0800 Subject: [PATCH] fix #3193 --- src/storage/mutate/AddEdgesProcessor.cpp | 2 +- src/storage/mutate/AddVerticesProcessor.cpp | 2 +- tests/tck/features/index/Index.IntVid.feature | 51 +++++++++++++++++++ tests/tck/features/index/Index.feature | 51 +++++++++++++++++++ 4 files changed, 104 insertions(+), 2 deletions(-) diff --git a/src/storage/mutate/AddEdgesProcessor.cpp b/src/storage/mutate/AddEdgesProcessor.cpp index bc266bd379c..0fa9bea1b57 100644 --- a/src/storage/mutate/AddEdgesProcessor.cpp +++ b/src/storage/mutate/AddEdgesProcessor.cpp @@ -200,7 +200,7 @@ void AddEdgesProcessor::doProcessWithIndex(const cpp2::AddEdgesRequest& req) { *edgeKey.edge_type_ref(), *edgeKey.ranking_ref(), (*edgeKey.dst_ref()).getStr()); - if (ifNotExists_ && !visited.emplace(key).second) { + if (!visited.emplace(key).second) { continue; } auto schema = env_->schemaMan_->getEdgeSchema(spaceId_, std::abs(*edgeKey.edge_type_ref())); diff --git a/src/storage/mutate/AddVerticesProcessor.cpp b/src/storage/mutate/AddVerticesProcessor.cpp index 4f3186864b0..335ca2408af 100644 --- a/src/storage/mutate/AddVerticesProcessor.cpp +++ b/src/storage/mutate/AddVerticesProcessor.cpp @@ -178,7 +178,7 @@ void AddVerticesProcessor::doProcessWithIndex(const cpp2::AddVerticesRequest& re } auto key = NebulaKeyUtils::vertexKey(spaceVidLen_, partId, vid, tagId); - if (ifNotExists_ && !visited.emplace(key).second) { + if (!visited.emplace(key).second) { continue; } auto props = newTag.get_props(); diff --git a/tests/tck/features/index/Index.IntVid.feature b/tests/tck/features/index/Index.IntVid.feature index a5534596fcd..5fb02e2e772 100644 --- a/tests/tck/features/index/Index.IntVid.feature +++ b/tests/tck/features/index/Index.IntVid.feature @@ -696,3 +696,54 @@ Feature: IndexTest_Vid_Int """ Then the execution should be successful Then drop the used space + + Scenario: intid duplicate vertex and edge when insert + Given an empty graph + And create a space with following options: + | partition_num | 9 | + | replica_factor | 1 | + | vid_type | int64 | + | charset | utf8 | + | collate | utf8_bin | + And having executed: + """ + CREATE TAG tag1(col1 string, col2 int, col3 double, col4 timestamp); + CREATE EDGE edge1(col1 string, col2 int, col3 double, col4 timestamp); + CREATE TAG INDEX tag1_index ON tag1(col2); + CREATE EDGE INDEX edge1_index ON edge1(col2); + """ + And wait 6 seconds + When executing query: + """ + INSERT VERTEX + tag1(col1, col2, col3, col4) + VALUES + 1:('Tom', 18, 35.4, `timestamp`('2010-09-01T08:00:00')), + 1:('Jerry', 22, 38.4, `timestamp`('2011-09-01T08:00:00')), + 1:('Bob', 19, 36.4, `timestamp`('2010-09-01T12:00:00')); + """ + Then the execution should be successful + When executing query: + """ + LOOKUP ON tag1 WHERE tag1.col2 < 20 YIELD tag1.col2 + """ + Then the result should be, in any order: + | VertexID | tag1.col2 | + | 1 | 18 | + When executing query: + """ + INSERT EDGE + edge1(col1, col2, col3, col4) + VALUES + 1 -> 2@0:('Tom', 18, 35.4, `timestamp`('2010-09-01T08:00:00')), + 1 -> 2@0:('Jerry', 22, 38.4, `timestamp`('2011-09-01T08:00:00')), + 1 -> 2@0:('Bob', 19, 36.4, `timestamp`('2010-09-01T12:00:00')); + """ + Then the execution should be successful + When executing query: + """ + LOOKUP ON edge1 WHERE edge1.col2 < 20 YIELD edge1.col2 + """ + Then the result should be, in any order: + | SrcVID | DstVID | Ranking | edge1.col2 | + | 1 | 2 | 0 | 18 | diff --git a/tests/tck/features/index/Index.feature b/tests/tck/features/index/Index.feature index 432dd06153c..f9401e074e0 100644 --- a/tests/tck/features/index/Index.feature +++ b/tests/tck/features/index/Index.feature @@ -943,3 +943,54 @@ Feature: IndexTest_Vid_String Then the result should be, in any order: | Tag Index Name | Create Tag Index | | "player_age_index" | "CREATE TAG INDEX `player_age_index` ON `player` (\n `age`\n)" | + + Scenario: stringid duplicate vertex and edge when insert + Given an empty graph + And create a space with following options: + | partition_num | 9 | + | replica_factor | 1 | + | vid_type | FIXED_STRING(30) | + | charset | utf8 | + | collate | utf8_bin | + And having executed: + """ + CREATE TAG tag1(col1 string, col2 int, col3 double, col4 timestamp); + CREATE EDGE edge1(col1 string, col2 int, col3 double, col4 timestamp); + CREATE TAG INDEX tag1_index ON tag1(col2); + CREATE EDGE INDEX edge1_index ON edge1(col2); + """ + And wait 6 seconds + When executing query: + """ + INSERT VERTEX + tag1(col1, col2, col3, col4) + VALUES + '1':('Tom', 18, 35.4, `timestamp`('2010-09-01T08:00:00')), + '1':('Jerry', 22, 38.4, `timestamp`('2011-09-01T08:00:00')), + '1':('Bob', 19, 36.4, `timestamp`('2010-09-01T12:00:00')); + """ + Then the execution should be successful + When executing query: + """ + LOOKUP ON tag1 WHERE tag1.col2 < 20 YIELD tag1.col2 + """ + Then the result should be, in any order: + | VertexID | tag1.col2 | + | '1' | 18 | + When executing query: + """ + INSERT EDGE + edge1(col1, col2, col3, col4) + VALUES + '1' -> '2'@0:('Tom', 18, 35.4, `timestamp`('2010-09-01T08:00:00')), + '1' -> '2'@0:('Jerry', 22, 38.4, `timestamp`('2011-09-01T08:00:00')), + '1' -> '2'@0:('Bob', 19, 36.4, `timestamp`('2010-09-01T12:00:00')); + """ + Then the execution should be successful + When executing query: + """ + LOOKUP ON edge1 WHERE edge1.col2 < 20 YIELD edge1.col2 + """ + Then the result should be, in any order: + | SrcVID | DstVID | Ranking | edge1.col2 | + | '1' | '2' | 0 | 18 |