使用StorageClient的scan_vertex时,alert修改Tag后,报了('parsed version %d is not equal to version %d provided', 256, 0)

  • nebula 版本:1.2.0
  • nebula-python=1.1.1

问题描述:
按照 https://github.com/vesoft-inc/nebula-python/blob/v1.0/examples/StorageClientExample.py#L135,
使用了scan_vertex,成功拿到了vertex数据;
但是当我对space中的tag增加列并且写入新的数据后,步骤如下:

step 1: alter tag team add(weight int);
step 2: instert vertex team(name,weight) values 14:('Lakers',12);

在使用scan_vertex获取数据就报了如下:

############# scanned vertex data #############
Traceback (most recent call last):
  File "./easy-kbrain/utiles/nebulaclient/NebulaStorageHandle.py", line 50, in scan_vertex
    process_vertex(space, scan_vertex_response)
  File "./easy-kbrain/utiles/nebulaclient/NebulaStorageHandle.py", line 89, in process_vertex
    result = scan_vertex_processor.process(space, scan_vertex_response)
  File "/export/anaconda3/envs/graph/lib/python3.6/site-packages/nebula_python-1.1.1-py3.6.egg/nebula/ngStorage/ngProcessor/ScanVertexProcessor.py", line 60, in process
    properties = row_reader.decode_value(scan_tag.value)
  File "/export/anaconda3/envs/graph/lib/python3.6/site-packages/nebula_python-1.1.1-py3.6.egg/nebula/ngData/data.py", line 90, in decode_value
    raise Exception('parsed version %d is not equal to version %d provided', ver, schema_version)
Exception: ('parsed version %d is not equal to version %d provided', 256, 0)
('parsed version %d is not equal to version %d provided', 256, 0)

想请问:parsed version 为啥要和 schema_version 比较,我屏蔽调判断逻辑后是可以正常输出的?

感谢您的提问,因为你读到的数据是用的旧版本的schema数据,假如直接用新版本处理会异常的,这里只是简单的报错了。正常的流程需要做些处理,比如新加的字段要填默认值,删除的字段要跳过,字段类型修改了需要做类型转换等等。这是个bug,我们尽快修复。

1 个赞
def process_vertex(space, scan_vertex_response):
    for vertex in scan_vertex_response.rows:
        # 假设scan_vertex_response的每个row有version信息
        data_version = vertex.schema_version
        current_schema_version = 256  # 这是你的新版本号
        
        if data_version != current_schema_version:
            # 这里需要处理版本差异,比如填充默认值或跳过不兼容的字段
            # 这只是概念性的,需要根据具体情况实现
            if data_version < current_schema_version:
                # 比如,旧数据没有'weight',我们填充默认值
                vertex.properties['weight'] = 0  # 设定一个默认值
            
        # 继续处理其他逻辑
        # ...