我已经使用一个独立实例和一个嵌入式实例设置了一个 HA 集群。
当嵌入式实例是从属并且我有更长的交易时间(提交时间大约 30 秒)时,它会抛出:
org.neo4j.graphdb.TransactionFailureException: Unable to commit transaction
at org.neo4j.kernel.TopLevelTransaction.finish(TopLevelTransaction.java:143)
... 4 more
Caused by: org.neo4j.com.TransactionNotPresentOnMasterException: Transaction RequestContext[session: 1372752815336, ID:3, eventIdentifier:0, [lucene-index/1311102, nioneodb/7397657]] has either timed out on the master or was not started on this master. There may have been a master switch between the time this transaction started and up to now. This transaction cannot continue since the state from the previous master isn't transferred.
at org.neo4j.kernel.ha.com.master.MasterImpl.suspendOtherAndResumeThis(MasterImpl.java:280)
at org.neo4j.kernel.ha.com.master.MasterImpl.finishTransaction(MasterImpl.java:457)
at org.neo4j.kernel.ha.com.HaRequestType18$14.call(HaRequestType18.java:188)
at org.neo4j.kernel.ha.com.HaRequestType18$14.call(HaRequestType18.java:183)
at org.neo4j.com.Server$4.run(Server.java:559)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:722)
如异常中所述,我检查了独立实例是否丢失了它的主状态,但它没有。所以不会发生主开关。这些实例在同一台机器上运行,因此网络错误不可能是原因。
当嵌入式实例是主实例或不在任何集群中时,事务成功。
产生这个错误的代码相当复杂,所以我不能在这里举个例子。