Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

batch update边属性失败,报错 The sort key values either be null or equal to origin when specified edge id #1442

Closed
jzhao833 opened this issue May 7, 2021 · 6 comments

Comments

@jzhao833
Copy link

jzhao833 commented May 7, 2021

Expected behavior 期望表现

通过 PUT http://127.0.0.1:8080/graphs/hugegraph/graph/edges/batch 批量更新边属性

Actual behavior 实际表现

在edgeLabel没有sortKey的情况下报错

{
    "exception": "class java.lang.IllegalArgumentException",
    "message": "The sort key values either be null or equal to origin when specified edge id",
    "cause": ""
}

如果请求体里去掉id字段,是可以正常更新的

Steps to reproduce the problem 复现步骤

  1. 请求体如下
{
    "edges":[
        {
            "id":"S1:josh>2>>S2:ripple",
            "label":"created",
            "outV":"1:josh",
            "outVLabel":"person",
            "inV":"2:ripple",
            "inVLabel":"software",
            "properties":{
                "weight":0.1,
                "date":"1522835200000"
            }
        }
    ],
    "update_strategies":{
        "weight":"SUM",
        "date":"BIGGER"
    },
    "check_vertex": false,
    "create_if_not_exist":true
}

#### Vertex/Edge example 数据示例
{
    "edges": [
        {
            "id": "S1:josh>2>>S2:lop",
            "label": "created",
            "type": "edge",
            "outV": "1:josh",
            "outVLabel": "person",
            "inV": "2:lop",
            "inVLabel": "software",
            "properties": {
                "weight": 0.4,
                "date": "20091111"
            }
        },
        {
            "id": "S1:josh>2>>S2:ripple",
            "label": "created",
            "type": "edge",
            "outV": "1:josh",
            "outVLabel": "person",
            "inV": "2:ripple",
            "inVLabel": "software",
            "properties": {
                "weight": 1.0,
                "date": "20171210"
            }
        },
        {
            "id": "S1:marko>1>20130220>S1:josh",
            "label": "knows",
            "type": "edge",
            "outV": "1:marko",
            "outVLabel": "person",
            "inV": "1:josh",
            "inVLabel": "person",
            "properties": {
                "weight": 1.0,
                "date": "20130220"
            }
        },
        {
            "id": "S1:marko>1>20160110>S1:vadas",
            "label": "knows",
            "type": "edge",
            "outV": "1:marko",
            "outVLabel": "person",
            "inV": "1:vadas",
            "inVLabel": "person",
            "properties": {
                "weight": 0.5,
                "date": "20160110"
            }
        },
        {
            "id": "S1:marko>2>>S2:lop",
            "label": "created",
            "type": "edge",
            "outV": "1:marko",
            "outVLabel": "person",
            "inV": "2:lop",
            "inVLabel": "software",
            "properties": {
                "weight": 0.4,
                "date": "20171210"
            }
        },
        {
            "id": "S1:peter>2>>S2:lop",
            "label": "created",
            "type": "edge",
            "outV": "1:peter",
            "outVLabel": "person",
            "inV": "2:lop",
            "inVLabel": "software",
            "properties": {
                "weight": 0.2,
                "date": "20170324"
            }
        }
    ]
}

#### Schema(VertexLabel, EdgeLabel, IndexLabel) 元数据结构
{
    "edgelabels": [
        {
            "id": 1,
            "name": "knows",
            "source_label": "person",
            "target_label": "person",
            "frequency": "MULTIPLE",
            "sort_keys": [
                "date"
            ],
            "nullable_keys": [
                "weight"
            ],
            "index_labels": [
                "knowsByWeight"
            ],
            "properties": [
                "weight",
                "date"
            ],
            "status": "CREATED",
            "ttl": 0,
            "enable_label_index": true,
            "user_data": {
                "~create_time": "2021-04-30 14:59:07.455"
            }
        },
        {
            "id": 2,
            "name": "created",
            "source_label": "person",
            "target_label": "software",
            "frequency": "SINGLE",
            "sort_keys": [],
            "nullable_keys": [
                "weight"
            ],
            "index_labels": [
                "createdByDate",
                "createdByWeight"
            ],
            "properties": [
                "weight",
                "date"
            ],
            "status": "CREATED",
            "ttl": 0,
            "enable_label_index": true,
            "user_data": {
                "~create_time": "2021-04-30 14:59:07.481"
            }
        }
    ]
}

Specifications of environment 环境信息

  • hugegraph version: server版本是0.11.2
  • hugegraph backend: HBase
@jzhao833 jzhao833 changed the title batch update边属性失败 batch update边属性失败,报错 The sort key values either be null or equal to origin when specified edge id May 7, 2021
@javeme
Copy link
Contributor

javeme commented May 7, 2021

@jzhao833 请问下请求中的edge-id是来自于哪里呢? 比如:"S1:josh>2>>S2:ripple"
如果是来自低版本的话,有可能导致id格式不兼容。最好在请求体里去掉id字段的时候,看看返回的id是什么内容。

@jzhao833
Copy link
Author

jzhao833 commented May 7, 2021

@javeme edgeId是来自于当前版本创建的边自动生成的ID,目前在请求体中去掉id字段的话是可以batchUpdate成功的,返回的id也是"id": "S1:josh>2>>S2:ripple",

@imbajin
Copy link
Member

imbajin commented May 7, 2021

简单看了下, 似乎问题是这样:

  1. 首先报错是因为之前的一个 issue Batch update edge with edgeId and unmatched sortKeys will create a new edge #818 里规定了当传入 edgeId 时, 会检查它和程序自己拼接成的 edgeId 是否一致,
  2. 一般来说不一致是 sortkey 不同导致, 所以之前提示的是关于 sortkey 的, 这里应该调整一下说明方式, 然后输出一下不一致的两个 edgeId 具体是什么, 方便用户排查 ( refact: improve error info of edge-update-api #1443 )

然后你这里如果没用低版生成 id, 又没有 sortKey, 又能确定顶点 id 和边 id 都和 server 返回一致, 那快速定位的话, 可以稍后用 Arthas 动态加载一下代码, 输出一下看看系统拼接的 edgeId 是什么, 如下命令即可:

# 1. 下载更新后的代码
wget -P /tmp https://raw.githubusercontent.com/hugegraph/hugegraph/467db581efb9752258682ebdb82dee9b9738e78d/hugegraph-api/src/main/java/com/baidu/hugegraph/api/graph/EdgeAPI.java

# ⬇️ Arthas 内完成下面两步 ⬇️
# 2. 重新编译
$ sc -d *EdgeAPI # 获取 classLoaderHash
$ mc -c xxx /tmp/EdgeAPI.java -d /tmp  # 'xxx' 对应使用上一步获取的 hash 值

# 3. 重新加载, 然后重新测试看看输出
$ redefine /tmp/com/baidu/hugegraph/api/graph/EdgeAPI.class

@jzhao833
Copy link
Author

jzhao833 commented May 7, 2021

@imbajin 好的,我稍后等代码update之后试一下
如果发生了你说的传入的edgeId和程序自己拼接的edgeId不一致的话,那我通过传入的id去查询edge也应该是查不到的吧,但目前是可以通过我传入的id获取这个Edge的详细信息

@imbajin
Copy link
Member

imbajin commented May 7, 2021

@imbajin 好的,我稍后等代码update之后试一下
如果发生了你说的传入的edgeId和程序自己拼接的edgeId不一致的话,那我通过传入的id去查询edge也应该是查不到的吧,但目前是可以通过我传入的id获取这个Edge的详细信息

程序拼接的地方是更新边时临时调用的, 并非从后端存储层读取的数据, 所以你查询能查到并不代表拼接就是一致的

@imbajin
Copy link
Member

imbajin commented May 21, 2021

最新版代码已经默认添加相关日志, 暂时关闭 issue, 期待你的新反馈再开启

@imbajin imbajin closed this as completed May 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants