nebula-python删除space后,再创建space和schema,报如下错(已sleep9s)

  • nebula 版本:2.5.0
  • 部署方式:分布式
  • 安装方式: Docker
  • 是否为线上版本:N
self.client.execute( f'DROP SPACE IF EXISTS {db_name};' )

self.client.execute( f'CREATE SPACE IF NOT EXISTS {db_name}(vid_type=FIXED_STRING({vid_length}));USE {db_name};' )

    def create_tags(self, tags):
        '''
        # 创建TAG
        '''
        for tag_name, properties_dict in tags.items():
            properties_lst = []
            for k, v in properties_dict.items():
                properties = k + ' ' + v
                properties_lst.append(properties)

            properties_str = ','.join(properties_lst)

            self.client.execute(
                f'CREATE TAG IF NOT EXISTS {tag_name}({properties_str});'
            )
            print(f"【Schema】创建TAG {tag_name}成功!")

    def create_edges(self, edges):
        '''
        # 创建EDGE
        '''
        for edge_name, properties_dict in edges.items():
            properties_lst = []
            for k, v in properties_dict.items():
                properties = k + ' ' + v
                properties_lst.append(properties)

            properties_str = ','.join(properties_lst)

            self.client.execute(
                f'CREATE EDGE IF NOT EXISTS {edge_name} ({properties_str});'
            )
            print(f"【Schema】创建EDGE {edge_name}成功!")

 def insert_graph_vertex(self, tag_name, vertexs):
        '''
        # 插入vertexs
        '''
        values_str = ','.join(
            [f"'{k}':{tuple(v.values())}" for k, v in vertexs.items() if not (isinstance(k, float) and np.isnan(k))])
        resp = self.client.execute(
            f'INSERT VERTEX IF NOT EXISTS {tag_name} VALUES {values_str}')
        try:
            assert resp.is_succeeded(), resp.error_msg()
        except:
            print(111,values_str)
        print(f"【Data】插入节点{tag_name}成功!({len(vertexs.keys())})")

Traceback (most recent call last):
  File "/root/jx/kgp/utils/nebula_db.py", line 370, in <module>
    test()
  File "/root/jx/kgp/utils/nebula_db.py", line 362, in test
    conn.insert_graph_edge(relations)
  File "/root/jx/kgp/utils/nebula_db.py", line 217, in insert_graph_edge
    assert resp.is_succeeded(), resp.error_msg()
AssertionError: EdgeName `liveIn'  is nonexistent

创建点和边后sleep一下,创建是异步的,创建完直接插入,可能点和边还没有创建成功。

1 个赞

已经sleep了9s了,还是会有这个问题……

您的心跳时间有调整过么?默认的话9s是不够的哈

https://docs.nebula-graph.com.cn/2.6.1/2.quick-start/4.nebula-graph-crud/#_1

那对于这种情况,我是把默认的心跳时间改短些好,还是把我的sleep时间调长些好呢?调短默认心跳时间会不会带来别的问题?

心跳短的话,集群的同步的资源占用会大一些,可以通过这篇文章了解一下哈:

https://nebula-graph.com.cn/posts/cluster-communication-heartbeat/

好的,谢谢

此话题已在最后回复的 30 天后被自动关闭。不再允许新回复。