apache / apache/hugegraph

[Bug] Adding edges in batch mode throws exception that trace is 'Undefined link of edge label'

Open
#2,368 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
3.2k
Forks
636
Avg merge
3d 11h
Merged PRs (30d)
14

Description

### Bug Type (问题类型)

rest-api (结果不合预期)

### Before submit

- [X] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 [FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have confirmed and searched that there are no similar problems in the historical issue and documents)

### Environment (环境信息)

Server Version: 1.0.0 (Apache Release Version)
Backend: RocksDB 1 nodes, HDD
OS: CentOS 7.x

### Expected & Actual behavior (期望与实际表现)

```java
HugeClient hugeClient = HugeClient.builder("http://master:8080", "hugegraph").build();
// times, batch_no, object_key, from_key, to_key, _event_ids, date_time
Edge edge = new Edge("emp_gen_edges");
edge.sourceLabel("employee");
edge.targetLabel("employee");
edge.sourceId("3:153541189818181621");
edge.targetId("3:153541189818181616");

edge.property("from_key", "from_0199001992900221");
edge.property("to_key", "to_99001992900221");
edge.property("date_time", "2023-11-30");
edge.property("batch_no", "1130_19_51");
edge.property("times", 3);
edge.property("object_key", "11300199001992900221_03");
edge.property("_event_ids", Collections.emptyList());

// 调用hugeClient.graph().addEdges()方法,主要测checkVertex为false时是否可写入,跳过实体点的检测。先写入关系边、再写入实体,但抛出了异常。
List edges = hugeClient.graph().addEdges(Arrays.asList(edge), false);
LOGGER.info("edgeId: [{}], attrVal: [{}]", edges.get(0).id(), JSON.toJSONString(edge));
```

执行批量实体点写入,完整的错误堆栈如下:
```
java.lang.IllegalStateException: Failed to execute CommandLineRunner
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:779) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:322) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
at org.apache.huge.HugegraphApp.main(HugegraphApp.java:51) [classes/:na]
Caused by: org.apache.hugegraph.exception.ServerException: Undefined link of edge label 'emp_gen_edges': 'employee' -> 'employee'
at org.apache.hugegraph.exception.ServerException.fromResponse(ServerException.java:45) ~[hugegraph-client-1.0.0.jar:1.0.0]
at org.apache.hugegraph.client.RestClient.checkStatus(RestClient.java:91) ~[hugegraph-client-1.0.0.jar:1.0.0]
at org.apache.hugegraph.rest.AbstractRestClient.post(AbstractRestClient.java:232) ~[hugegraph-common-1.0.0.jar:1.0.0]
at org.apache.hugegraph.api.graph.EdgeAPI.create(EdgeAPI.java:58) ~[hugegraph-client-1.0.0.jar:1.0.0]
at org.apache.hugegraph.driver.GraphManager.addEdges(GraphManager.java:262) ~[hugegraph-client-1.0.0.jar:1.0.0]
at org.apache.huge.HugegraphApp.run(HugegraphApp.java:90) [classes/:na]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:795) [spring-boot-2.3.3.RELEASE.jar:2.3.3.RELEASE]
... 5 common frames omitted
Disconnected from the target VM, address: '127.0.0.1:57474', transport: 'socket'
```

当使用单个edge写入时,关系数据是可以正常写入的(如下方代码所示),但批量写入存在问题:
```
Edge edge_insert = hugeClient.graph().addEdge(edge);
```

### Vertex/Edge example (问题点 / 边数据举例)

_No response_

### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.