知识库

错误解释 “Unrecognized transaction id. Transaction may have timed out and been rolled back”

在通过 Neo4j 事务性 Cypher HTTP 端点提交请求时,可能会遇到以下错误

Unrecognized transaction id.
Transaction may have timed out and been rolled back

此错误可能是因为事务的到期日期/时间已到达而导致的。默认情况下,org.neo4j.server.transaction.timeout 描述了事务在不活动多久后将自动回滚的秒数。默认值为 60 秒,但可以通过在 conf/neo4j-server.properties 中添加以下内容来覆盖

org.neo4j.server.transaction.timeout=XXX

其中 XXX 表示秒数,然后通过 bin/neo4j restart 重启 Neo4j。

另一种做法是通过定期使用 REST API 执行 keep‑alive 来保持事务打开,如 /db/data/transaction/XXX 所述,或者通过 /db/data/transaction/XXX/commit 提前提交事务,其中 XXX 表示事务号。

注意 bin/neo4j-shell 不使用 REST API,因此 org.neo4j.server.transaction.timeout 对在 neo4j-shell 中通过 begin/commit 创建的事务没有影响。

© . This site is unofficial and not affiliated with Neo4j, Inc.