dosubot[bot] commented on issue #2827:
URL: 
https://github.com/apache/incubator-hugegraph/issues/2827#issuecomment-3061607638

   <!-- Answer -->
   你遇到的 LimitExceedException(“Too many records(must <= 800000) for the 
query...”)是 HugeGraph 的预期行为,不是 bug。原因是删除一个顶点时,HugeGraph 
会先枚举并删除该顶点所有关联的边(入边和出边),如果边的数量超过配置的阈值(默认 80 
万),就会抛出这个异常来保护系统资源,防止单次操作占用过多内存或事务容量。这一限制在 REST API 和 Gremlin 
任务中都会被严格检查,底层实现和配置详见源码说明
   
[1](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/exception/LimitExceedException.java)
   
[2](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java)
   
[3](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java)。
   
   如果确实需要删除这种“高连接”顶点,建议先分批删除该顶点的所有边,再删除顶点本身。可以用 Gremlin 脚本分页删除边,例如:
   
   ```groovy
   // 分页删除出边
   while (true) {
     edges = g.V('2:@I').outE().limit(1000).toList();
     if (edges.size() == 0) break;
     edges.each { it.remove() }
     graph.tx().commit()
   }
   // 分页删除入边
   while (true) {
     edges = g.V('2:@I').inE().limit(1000).toList();
     if (edges.size() == 0) break;
     edges.each { it.remove() }
     graph.tx().commit()
   }
   // 最后删除顶点
   g.V('2:@I').drop().iterate()
   graph.tx().commit()
   ```
   
   参数 limit 可以根据实际情况调整(建议远小于 8w),每次 commit 保证不会超出事务容量(相关配置如 
edge.tx_capacity、vertex.part_edge_commit_size 可参考
   
[CoreOptions.java](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java))。
   
   不建议直接调高 query.limit(默认 800000),否则容易导致 OOM 或影响集群稳定性。
   
   目前 REST API 没有直接支持分页删除边的接口,只能通过 Gremlin 脚本实现批量删除。
   
   如需自动化处理多个顶点,可将上述逻辑封装为脚本循环处理。
   
   参考源码与配置说明:
   - [LimitExceedException 
实现](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/exception/LimitExceedException.java)
   - 
[相关配置项](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-core/src/main/java/org/apache/hugegraph/config/CoreOptions.java)
   - [VertexAPI 
删除顶点实现](https://github.com/apache/incubator-hugegraph/blob/a53af864b31f803780a1db31cb20d3d94d5d34fc/hugegraph-server/hugegraph-api/src/main/java/org/apache/hugegraph/api/graph/VertexAPI.java)
   
   
   <!-- Dosu Comment Footer -->
   *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).*
   
   ---
   <sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/91147508-e870-447f-b0da-a7d93db54c22?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/91147508-e870-447f-b0da-a7d93db54c22?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/91147508-e870-447f-b0da-a7d93db54c22?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/91147508-e870-447f-b0da-a7d93db54c22?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/91147508-e870-447f-b0da-a7d93db54c22?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/91147508-e870-447f-b0da-a7d93db54c22?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/91147508-e870-447f-b0da-a7d93db54c22?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[!
 [Share on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/incubator-hugegraph/issues/2827)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to