nebula 使用reversely 查询问题?

提问参考模版:

  • nebula 版本:3.1.0
  • 部署方式:分布式
  • 安装方式:未知
  • 是否为线上版本:N
  • 硬件信息
    • 磁盘 未知
    • CPU、内存信息 未知

查询语句 :

GO 1 to 100 steps FROM  "A" OVER follow  REVERSELY  
where properties(edge).deleted == 0  yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo 

问题描述:A点->B点 由于这条边的信息中携带一个deleted 字段 用于判断暂时A点不指向B点,但是使用 REVERSELY 还是会返回结果B->A的数据?

A->B 这条边的 deleted 是1 ?

是的,deleted 状态是1 但是REVERSELY 查询后 还是查询出数据。

我试了下,是可以过滤的,你可能需要检查一下你的数据。

(root@nebula) [nba]> go 1 to 100 steps  from "Ray Allen" over * REVERSELY where properties(edge).likeness ==101 yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo
+-------+-------+----------+---------+---------+----------+
| srcId | dstId | edgeName | srcTags | dstTags | edgeInfo |
+-------+-------+----------+---------+---------+----------+
+-------+-------+----------+---------+---------+----------+
Empty set (time spent 271611/272192 us)

可以使用以下数据进行查询
INSERT VERTEX player(name, age,deleted) VALUES “player100”:(“Tim Duncan”, 42,0);
INSERT VERTEX player(name, age,deleted) VALUES “player101”:(“Tony Parker”, 36,0);
INSERT VERTEX player(name, age,deleted) VALUES “player102”:(“LaMarcus Aldridge”, 33,0);

INSERT EDGE follow(degree,deleted) VALUES “player101” → “player100”:(95,0);
INSERT EDGE follow(degree,deleted) VALUES “player102” → “player101”:(96,0);

#此时去查没问题 player102->player101->player100
GO 1 to 100 steps FROM “player100” OVER follow REVERSELY where properties(edge).deleted == 0 yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo

#更新边为删除
UPDATE EDGE “player101” → “player100” OF follow SET deleted = 1;

#插入一个新点与新的边
INSERT VERTEX player(name, age,deleted) VALUES “player103”:(“Luka”, 23,0);

INSERT EDGE follow(degree,deleted) VALUES “player100” → “player103”:(95,0);

#再查询后会查询出 “player102” → “player101”
GO 1 to 100 steps FROM “player100” OVER follow REVERSELY where properties(edge).deleted == 0 yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo

按照个人理解是否"player102" → "player101"应该不显示,因为已经打断与player100 与 player101 之间的关系了?

哦哦。我猜测UPDATE EDGE这里有个bug。

可以从100 reversely 到101,返回下 edge.deleted.

所以我该如何处理 “player102” → "player101"这种数据,因为查询的时候已经不会返回“player101” → “player100”的任何信息,edge.deleted.已经无法筛选

我似乎不能重现问题, GRAPHD 11.15 master; STORAGED 3.3.0

(root@nebula) [basketballplayer]> create space test0(partition_num=10,replica_factor=1,vid_type=fixed_string(32));
Execution succeeded (time spent 3795/14195 us)


(root@nebula) [basketballplayer]> use test0
Execution succeeded (time spent 1370/14198 us)

Mon, 28 Nov 2022 19:15:27 CST

(root@nebula) [test0]> create tag player(name string,age int, deleted int);
Execution succeeded (time spent 3901/10744 us)

Mon, 28 Nov 2022 19:15:35 CST

(root@nebula) [test0]> create tag team(name string);
Execution succeeded (time spent 3044/8084 us)

Mon, 28 Nov 2022 19:15:35 CST

(root@nebula) [test0]> create edge serve(start_year int,end_year int);
Execution succeeded (time spent 3108/8071 us)

Mon, 28 Nov 2022 19:15:35 CST

(root@nebula) [test0]> create edge follow(degree int, deleted int);
Execution succeeded (time spent 3487/16966 us)

Mon, 28 Nov 2022 19:15:35 CST

(root@nebula) [test0]> INSERT VERTEX player(name, age,deleted) VALUES "player100":("Tim Duncan", 42,0);
Execution succeeded (time spent 1829/10416 us)

Mon, 28 Nov 2022 19:15:44 CST

(root@nebula) [test0]> INSERT VERTEX player(name, age,deleted) VALUES "player101":("Tony Parker", 36,0);
Execution succeeded (time spent 1491/7126 us)

Mon, 28 Nov 2022 19:15:44 CST

(root@nebula) [test0]> INSERT VERTEX player(name, age,deleted) VALUES "player102":("LaMarcus Aldridge", 33,0);
Execution succeeded (time spent 1729/8454 us)

Mon, 28 Nov 2022 19:15:44 CST

(root@nebula) [test0]>
(root@nebula) [test0]> INSERT EDGE follow(degree,deleted) VALUES "player101" -> "player100":(95,0);
Execution succeeded (time spent 1388/7329 us)

Mon, 28 Nov 2022 19:15:44 CST

(root@nebula) [test0]> INSERT EDGE follow(degree,deleted) VALUES "player102" -> "player101":(96,0);
Execution succeeded (time spent 1468/7281 us)

Mon, 28 Nov 2022 19:15:44 CST

(root@nebula) [test0]>
(root@nebula) [test0]> GO 1 to 100 steps FROM "player100" OVER follow REVERSELY  where properties(edge).deleted == 0  yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| srcId       | dstId       | edgeName | srcTags                                                               | dstTags                                                         | edgeInfo                                                       |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| "player101" | "player100" | "follow" | ("player101" :player{age: 36, deleted: 0, name: "Tony Parker"})       | ("player100" :player{age: 42, deleted: 0, name: "Tim Duncan"})  | [:follow "player101"->"player100" @0 {degree: 95, deleted: 0}] |
| "player102" | "player101" | "follow" | ("player102" :player{age: 33, deleted: 0, name: "LaMarcus Aldridge"}) | ("player101" :player{age: 36, deleted: 0, name: "Tony Parker"}) | [:follow "player102"->"player101" @0 {degree: 96, deleted: 0}] |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
Got 2 rows (time spent 9908/20625 us)

Mon, 28 Nov 2022 19:15:53 CST

(root@nebula) [test0]> UPDATE EDGE "player101" -> "player100" OF follow SET deleted = 1;
Execution succeeded (time spent 3246/8908 us)

Mon, 28 Nov 2022 19:16:07 CST

(root@nebula) [test0]> INSERT VERTEX player(name, age,deleted) VALUES "player103":("Luka", 23,0);
Execution succeeded (time spent 1775/7270 us)

Mon, 28 Nov 2022 19:16:12 CST

(root@nebula) [test0]> INSERT EDGE follow(degree,deleted) VALUES "player100" -> "player103":(95,0);
Execution succeeded (time spent 1709/6850 us)

Mon, 28 Nov 2022 19:16:22 CST

## 可以看到 player101-player100 的被如期待过滤掉了

(root@nebula) [test0]> GO 1 to 100 steps FROM "player100" OVER follow REVERSELY  where properties(edge).deleted == 0  yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| srcId       | dstId       | edgeName | srcTags                                                               | dstTags                                                         | edgeInfo                                                       |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| "player102" | "player101" | "follow" | ("player102" :player{age: 33, deleted: 0, name: "LaMarcus Aldridge"}) | ("player101" :player{age: 36, deleted: 0, name: "Tony Parker"}) | [:follow "player102"->"player101" @0 {degree: 96, deleted: 0}] |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
Got 1 rows (time spent 10025/17533 us)
(root@nebula) [test0]> SHOW HOSTS GRAPH
+-----------+------+----------+---------+--------------+----------------------+
| Host      | Port | Status   | Role    | Git Info Sha | Version              |
+-----------+------+----------+---------+--------------+----------------------+
| "graphd"  | 9669 | "ONLINE" | "GRAPH" | "a5c08a6"    | "2022.11.15-nightly" |
| "graphd1" | 9669 | "ONLINE" | "GRAPH" | "c9f84b1"    | "3.3.0"              |
| "graphd2" | 9669 | "ONLINE" | "GRAPH" | "c9f84b1"    | "3.3.0"              |
+-----------+------+----------+---------+--------------+----------------------+
Got 3 rows (time spent 1678/15745 us)

Mon, 28 Nov 2022 19:19:52 CST

(root@nebula) [test0]> SHOW HOSTS storage
+-------------+------+----------+-----------+--------------+---------+
| Host        | Port | Status   | Role      | Git Info Sha | Version |
+-------------+------+----------+-----------+--------------+---------+
| "storaged0" | 9779 | "ONLINE" | "STORAGE" | "c9f84b1"    | "3.3.0" |
| "storaged1" | 9779 | "ONLINE" | "STORAGE" | "c9f84b1"    | "3.3.0" |
| "storaged2" | 9779 | "ONLINE" | "STORAGE" | "c9f84b1"    | "3.3.0" |
+-------------+------+----------+-----------+--------------+---------+
Got 3 rows (time spent 1631/13748 us)

你可以在新的数据上 100% 复现么?我怀疑是 edge partially write 了。

我感觉应该是很 rare 的 case,边写失败了,只成了一边(因为边是有两份的,一致性默认是不保证的)。

如果想保证边的一致性,开启 TOSS 这个开关是可以完全规避这个问题的,不过代价是性能,边数据更改时候会有锁。

其实您已经复现出来了,只是我问题描述的点在于,我查询的是球员“player100”,REVERSELY的时候我不想看到数据"player102" ->“player101” 因为按照我的理解 “player101”->“player100” 已经被打断了。"player102"更不可能与"player100"发生联系

@caton-hpg 似乎这个目前 Filter 是在 GetNeighbors 之后 applied 的(而不是嵌在 GetNeighbors 里),所以实际上只应用在了最后一跳,这是期待中的语义么?还是说本质上是 https://github.com/vesoft-inc/nebula/issues/4573

player101 -- player100 # deleted = 0
player102 -- player101

结果
player101 -- player100
player100--player102--player101 
(root@nebula) [test0]> GO 1 to 100 steps FROM "player100" OVER follow REVERSELY  where properties(edge).deleted == 0  yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| srcId       | dstId       | edgeName | srcTags                                                               | dstTags                                                         | edgeInfo                                                       |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| "player101" | "player100" | "follow" | ("player101" :player{age: 36, deleted: 0, name: "Tony Parker"})       | ("player100" :player{age: 42, deleted: 0, name: "Tim Duncan"})  | [:follow "player101"->"player100" @0 {degree: 95, deleted: 0}] |
| "player102" | "player101" | "follow" | ("player102" :player{age: 33, deleted: 0, name: "LaMarcus Aldridge"}) | ("player101" :player{age: 36, deleted: 0, name: "Tony Parker"}) | [:follow "player102"->"player101" @0 {degree: 96, deleted: 0}] |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
Got 2 rows (time spent 9908/20625 us)

Mon, 28 Nov 2022 19:15:53 CST
player101 -- player100 # deleted = 1
player102 -- player101
player100 -- player103

结果
player100--player102--player101 
(root@nebula) [test0]> GO 1 to 100 steps FROM "player100" OVER follow REVERSELY  where properties(edge).deleted == 0  yield src(edge) as srcId, dst(edge) as dstId,type(edge) as edgeName,$$ as srcTags,$^ as dstTags,edge as edgeInfo
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| srcId       | dstId       | edgeName | srcTags                                                               | dstTags                                                         | edgeInfo                                                       |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
| "player102" | "player101" | "follow" | ("player102" :player{age: 33, deleted: 0, name: "LaMarcus Aldridge"}) | ("player101" :player{age: 36, deleted: 0, name: "Tony Parker"}) | [:follow "player102"->"player101" @0 {degree: 96, deleted: 0}] |
+-------------+-------------+----------+-----------------------------------------------------------------------+-----------------------------------------------------------------+----------------------------------------------------------------+
Got 1 rows (time spent 10025/17533 us)

目前这个需要怎么处理?

@MuYi GO 中的 WHERE 条件语义要改成最后一跳么?

这真是一个完全无法理解的奇怪行为。变成了实现决定行为。