You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AWS Neptune并发插入独立子图触发ConcurrentModificationException咨询

AWS Neptune多并发写入独立子图时的ConcurrentModificationException问题

我们使用AWS Neptune数据库,目前遇到多用户同时保存数据时的异常问题:

图模型与操作流程

  • 图模型简化后:根顶点标签为"A",每个"A"可关联多个"B"顶点,每个"B"又可关联多个"C"顶点及其他关联顶点
  • 操作流程:启动事务,添加C、D、E、F、G顶点及关联边,提交事务

异常场景

当两个用户同时为完全独立的"A"顶点执行保存操作时(用户1为A(ID:4711)添加子图,用户2为A(ID:4712)添加子图,二者子图无任何关联),触发ConcurrentModificationException:

Caused by: java.util.concurrent.CompletionException: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"detailedMessage":"Failed to complete Insert operation for a Vertex due to conflicting concurrent operations. Please retry. 0 transactions are currently rolling back.","requestId":"64be5fdb-4208-4729-bc68-dccfecbfc87f","code":"ConcurrentModificationException"}
Caused by: org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"detailedMessage":"Failed to complete Insert operation for a Vertex due to conflicting concurrent operations. Please retry. 0 transactions are currently rolling back.","requestId":"64be5fdb-4208-4729-bc68-dccfecbfc87f","code":"ConcurrentModificationException"}

调试发现

  • 事务执行过程中,无法通过Jupyter Notebook添加"A"顶点,但可以插入未使用过的新标签"XYZ"顶点
  • 当前使用SERIALIZABLE隔离级别(参考Neptune官方文档中事务隔离级别与Gremlin事务相关内容)
  • 曾怀疑插入查询中的coalesce是问题根源(参考Stack Overflow上的类似问题),但测试仅执行g.addV("C")仍会触发异常

插入查询示例

g.V("f6e9a3ed-5b2e-400a-83f4-074af0fee71f").fold().coalesce(unfold(),addV("C").property(single,"status",'"abc"').property(T.id,"f6e9a3ed-5b2e-400a-83f4-074af0fee71f")).id().fold()

核心疑问

  1. 是否可以同时为不同的独立"A"顶点对应的子图执行写入操作?
  2. 经排查发现事务中的第一个查询会阻塞整个数据库,请问该查询为何会造成全局阻塞?

事务中第一个查询示例

g.V().hasLabel("A").has("v",4711).outE("s").inV()
.hasLabel("B").hasId("c4...a","a0...f","ac...3")
.outE("h").inV()
.bothE("sv","ev")
.bothV().not(hasLabel("C")).simplePath()
.barrier()
.repeat(outE().not(hasLabel("sv","ev")).simplePath().inV())
.until(or(outE().count().is(0),hasLabel("C"),hasLabel("AP","AC").bothE("sv","ev").count().is(P.gt(0))))
.path().unfold().dedup().or(hasLabel("sp").has("ev"),hasLabel("ev")).barrier()
.drop()

内容的提问来源于stack exchange,提问作者WobiHH

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.07 09:05:32