节点:16.20.2
gremlin:3.6.5
ResponseError: Server error:
{
"detailedMessage": "Failed to complete Insert operation for a Vertex due to conflicting concurrent operations. Please retry. 0 transactions are currently rolling back.",
"requestId": "804258c5-6b10-4abc-8d7f-659acaad0f15",
"code": "ConcurrentModificationException"
} (500)
下面提供的代码在大多数情况下成功地将数据插入AWS Neptune,但偶尔会失败,这是意料之中的。不幸的是,我无法到达catch子句,因为Gremlin驱动程序错误终止了服务器。我已经尝试了不同作用域中的各种catch子句,但问题仍然存在。当函数是一个promise时,错误率要高得多。
(编辑:按照Taylor Riggan的建议重构,问题仍然存在。)
private insertOrUpdateEdge(edge) {
const availableSince = new Date(edge['available_since']);
let insertQuery = __.V(edge.from).as('from').V(edge.to).addE(edge.label).from_('from').property(t.id, edge.id);
insertQuery = this.addProperties(insertQuery, edge);
let insertOrUpdateQuery;
try {
insertOrUpdateQuery = this.g
.E(edge.id)
.fold()
.coalesce(unfold(), insertQuery)
.has('available_since', P.gt(availableSince))
.property('available_since', availableSince)
.next();
} catch (err) {
this.insertOrUpdateEdge(edge);
}
}
1条答案
按热度按时间xoshrz7s1#
看起来好像您在
finally{}
块之前没有将Terminal Step [1]添加到查询中。需要终端步骤将查询发送到数据库。您应该在try{}
块中使用终端步骤(在本例中为next()
)。如果抛出异常,那么它将在catch{}
块中被捕获。[1]https://tinkerpop.apache.org/docs/current/reference/#terminal-steps