Star

UPSERT EDGE 创建出不可操作无法检索节点

  • nebula 版本:v2-nightly
  • 部署方式(分布式 / 单机 / Docker / DBaaS):分布式
  • 问题的具体描述
    使用UPSERT EDGE,添加了不存在节点的边,发现系统中自动创建不可操作无法检索节点,所有属性均为空(不是null),这样的幽灵边和幽灵节点存在会导致很多隐性问题。
    希望后续版本继续改进,要么不允许这样创建边,要么创建出合法节点,并添加对于该操作说明。

操作日志如下:

>>> nebula_db.show_stats('stock')
[2021-01-06 17:40:28,944]:loading stats ...
+-------+-------------+-------+
|  Type |     Name    | Count |
+-------+-------------+-------+
|  Tag  |   company   |  3188 |
|  Tag  |   concept   |  163  |
|  Tag  |   industry  |   49  |
|  Tag  |    person   | 20872 |
|  Tag  |   student   |   0   |
|  Edge |  concept_of |  9442 |
|  Edge |  employ_of  | 21418 |
|  Edge | industry_of |  2908 |
|  Edge |     like    |   0   |
| Space |   vertices  | 24271 |
| Space |    edges    | 33768 |
+-------+-------------+-------+
>>> src = 'xxxxx1'
>>> dst = 'xxxxx2'
>>> edge_name = 'like'
>>> change_info = {'like': 'xiaoming', 'likeness': 10.0}
>>> nebula_db.upsert_edges(src, dst, edge_name, change_info)
>>> nebula_db.show_stats('stock')
[2021-01-06 17:40:58,521]:loading stats ...
+-------+-------------+-------+
|  Type |     Name    | Count |
+-------+-------------+-------+
|  Tag  |   company   |  3188 |
|  Tag  |   concept   |  163  |
|  Tag  |   industry  |   49  |
|  Tag  |    person   | 20872 |
|  Tag  |   student   |   0   |(创建了边,创建了可以查询到的幽灵节点,但是索引不到且无法操作)
|  Edge |  concept_of |  9442 |
|  Edge |  employ_of  | 21418 |
|  Edge | industry_of |  2908 |
|  Edge |     like    |   1   |
| Space |   vertices  | 24271 |
| Space |    edges    | 33769 |
+-------+-------------+-------+

Concle查询记录如下:

(root@nebula) [stock]> FETCH PROP ON student "xxxxx2"
+----------+--------------+----------------+-------------+
| VertexID | student.name | student.gender | student.age |
+----------+--------------+----------------+-------------+
| "xxxxx2" |              |                |             |
+----------+--------------+----------------+-------------+
Got 1 rows (time spent 2166/3069 us)

Wed, 06 Jan 2021 17:40:49 CST

(root@nebula) [stock]> FETCH PROP ON student "xxxxx1"
+----------+--------------+----------------+-------------+
| VertexID | student.name | student.gender | student.age |
+----------+--------------+----------------+-------------+
| "xxxxx1" |              |                |             |
+----------+--------------+----------------+-------------+
Got 1 rows (time spent 1740/2631 us)

Wed, 06 Jan 2021 17:40:51 CST

(root@nebula) [stock]> UPDATE VERTEX 'xxxxx1' SET student.name='xxx' --无法操作
[ERROR (-8)]: Storage Error: Vertex or edge not found.

Wed, 06 Jan 2021 17:53:24 CST

(root@nebula) [stock]> FETCH PROP ON student "xxxxx1"
+----------+--------------+----------------+-------------+
| VertexID | student.name | student.gender | student.age |
+----------+--------------+----------------+-------------+
| "xxxxx1" |              |                |             |
+----------+--------------+----------------+-------------+
Got 1 rows (time spent 1763/2569 us)

Wed, 06 Jan 2021 17:53:30 CST


(root@nebula) [stock]> CREATE TAG INDEX student_index on student();
Execution succeeded (time spent 7087/7612 us)

Wed, 06 Jan 2021 17:43:41 CST

(root@nebula) [stock]> REBUILD TAG INDEX student_index;
+------------+
| New Job Id |
+------------+
| 140        |
+------------+
Got 1 rows (time spent 5385/6166 us)

Wed, 06 Jan 2021 17:44:17 CST

(root@nebula) [stock]> show job 140;
+----------------+---------------------+------------+------------+------------+
| Job Id(TaskId) | Command(Dest)       | Status     | Start Time | Stop Time  |
+----------------+---------------------+------------+------------+------------+
| 140            | "REBUILD_TAG_INDEX" | "FINISHED" | 1609926257 | 1609926257 |
+----------------+---------------------+------------+------------+------------+
| 0              | "192.168.4.172"     | "FINISHED" | 1609926257 | 1609926257 |
+----------------+---------------------+------------+------------+------------+
| 1              | "192.168.4.174"     | "FINISHED" | 1609926257 | 1609926257 |
+----------------+---------------------+------------+------------+------------+
| 2              | "192.168.4.173"     | "FINISHED" | 1609926257 | 1609926257 |
+----------------+---------------------+------------+------------+------------+
Got 4 rows (time spent 2156/3139 us)

Wed, 06 Jan 2021 17:44:26 CST

(root@nebula) [stock]> LOOKUP ON student --索引不到
Empty set (time spent 2773/3605 us)

  1. 看你stats的统计,没有点存在student这个tag。
  2. 然后你做update 一个点的student tag的时候,这个tag不存在,更新肯定也是失败的。
    3 FETCH 一个存在的点,但是你指定了fetch不存在的tag,给填empty值这样你觉得有什么问题吗? empty表示就是没这个属性。
1赞

抱歉抱歉,我对节点的概念理解出了一些问题,我以为节点一定要依附于某一个或者某几个tag而存在,没考虑到存在没有tag的节点。
我上一个帖子的问题也是这种原因导致的,我会去删掉那个问题,感谢大佬解答 :pray:

没考虑到存在没有tag的节点

我的回答里面有说存在没有tag的节点的?你是从哪里认为这个是对的。

一些问题,我以为节点一定要依附于某一个或者某几个tag而存在

nebula 节点是一定有tag存在的,允许tag没有属性,你上面的点 “xxxxx2” 和 “xxxxx1” 应该是存在的,只是他们没有student这个tag,你可以用fetch * 看它们有哪些tag

好的好的,我测试之后再来更新

使用 FETCH PROP ON * "xxxxx1"测试后返回结果如下,您看这是否说明点"xxxxx1"拥有所有TAG,但均没有属性?@dingding

(root@nebula) [stock]> FETCH PROP ON * "xxxxx1"
+----------+-------------+---------------+------------+--------------+--------------+--------------+---------------+--------------+----------------+-------------+
| VertexID | person.name | person.gender | person.age | company.name | company.code | concept.name | industry.name | student.name | student.gender | student.age |
+----------+-------------+---------------+------------+--------------+--------------+--------------+---------------+--------------+----------------+-------------+
| "xxxxx1" |             |               |            |              |              |              |               |              |                |             |
+----------+-------------+---------------+------------+--------------+--------------+--------------+---------------+--------------+----------------+-------------+
Got 1 rows (time spent 1954/3027 us)

Thu, 07 Jan 2021 09:57:31 CST

但是如果说明上述节点拥有所有TAG属性的话,使用FETCH PROP ON * 搜索现有的personTAG节点时,也返回同样效果:

(root@nebula) [stock]> FETCH PROP ON * "f99a6582a299fc9323e99c713d7a22a1"
+------------------------------------+-------------+---------------+------------+--------------+--------------+--------------+---------------+--------------+----------------+-------------+
| VertexID                           | person.name | person.gender | person.age | company.name | company.code | concept.name | industry.name | student.name | student.gender | student.age |
+------------------------------------+-------------+---------------+------------+--------------+--------------+--------------+---------------+--------------+----------------+-------------+
| "f99a6582a299fc9323e99c713d7a22a1" | "王正喜"    | "女"          | 58         |              |              |              |               |              |                |             |
+------------------------------------+-------------+---------------+------------+--------------+--------------+--------------+---------------+--------------+----------------+-------------+
Got 1 rows (time spent 2544/3731 us)

Thu, 07 Jan 2021 10:05:51 CST

没有属性就没有对应的tag

你通过 FETCH PROP ON * "xxxxx1" 可以拿到这个点,但是所有属性都是为空,我猜测,你的点 “xxxxx1” 曾经插入过 student 这个tag,但是我看你另一个pr把student这个tag drop 掉了(但是"xxxxx1" 这个点还是在的,需要做compacte把它清理掉,你可以执行下 SUBMIT JOB COMPACT;将这些已经被drop tag的点给清理掉,免得影响你的判断,这个后续我们也应该处理下)。然后你是不是又重新创建了student这个tag,所以在这个问题里我看到了student这个tag。虽然"xxxxx1"这个点实际是在的,但是它对应的tag id的student已经被drop掉了,所以它读不到任何属性。新的student的tag id是不能用于原来的数据的。

1赞

好的好的,原来是这样,生产中应该不会出现这种问题,谢谢大佬解惑 :pray:

浙ICP备20010487号