首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Neo4J BatchInserter与多线程

Neo4J BatchInserter与多线程
EN

Stack Overflow用户
提问于 2017-01-13 06:41:08
回答 1查看 254关注 0票数 0

我使用Neo4J BatchInserter从头开始建立一个大型数据库。我使用多个线程从BatchInserter读取数据并同步写入。

问题:在尝试读取属性时,迟早会遇到异常

  • 在DirectRecordAccess.putInBatc中启用断言
  • 当断言被禁用时,我在PropertyRecord.next中得到一个PropertyRecord.next 线程"main“中的异常:4在org.neo4j.kernel.impl.store.record.PropertyRecord.next(PropertyRecord.java:190) at org.neo4j.kernel.impl.store.record.PropertyRecord.next(PropertyRecord.java:41) at org.neo4j.kernel.impl.transaction.state.Loaders$2.ensureHeavy(Loaders.java:189) at org.neo4j.kernel.impl.transaction.state.Loaders$2.ensureHeavy(Loaders.java:161) at org.neo4j.unsafe.batchinsert.DirectRecordAccess$DirectRecordProxy.forReadingData(DirectRecordAccess.org.neo4j.unsafe.batchinsert.DirectRecordAccess$DirectRecordProxy.forReadingData(DirectRecordAccess.java:115) at org.neo4j.kernel.impl.transaction.state.PropertyTraverser.getPropertyChain(PropertyTraverser.java:65) at org.neo4j.unsafe.batchinsert.internal.BatchInserterImpl.getPropertyChain(BatchInserterImpl.java:1000) at org.neo4j.unsafe.batchinsert.internal.BatchInserterImpl.getNodeProperties(BatchInserterImpl.java:900)

JavaDoc声明:“一次只有一个线程可以对批处理插入器工作,执行并发访问的多个线程必须采用同步。”

问题:

  • BatchInserter线程安全用于只读操作吗?
  • 如果是的话,只要并发只读线程没有请求当前写入的数据,同步写入是否安全?

谢谢你的反馈!

吕迪格

EN

回答 1

Stack Overflow用户

发布于 2017-01-13 07:12:21

抱歉打扰了-我应该像现在一样测试一下。因此,对于所有想知道的人来说:似乎您甚至需要序列化读访问--或者确保不尝试对相同属性进行并发读取。

我测试的是:

  • 使用BatchInserter创建100个节点,每个节点具有一个字符串属性
  • 写2线程试图从无休止循环中的节点中获取属性

结果是:

  • 当两个线程从不同的节点读取属性时,一切都很好。
  • 当线程从同一节点读取时,将引发以下异常 线程" thread -2“中的异常( org.neo4j.kernel.impl.store.record.PropertyRecord.next(PropertyRecord.java:187) at org.neo4j.kernel.impl.store.record.PropertyRecord.next(PropertyRecord.java:41) at org.neo4j.kernel.impl.transaction.state.PropertyTraverser.getPropertyChain(PropertyTraverser.java:66) at org.neo4j.unsafe.batchinsert.internal.BatchInserterImpl.getPropertyChain(BatchInserterImpl.java:1000) at org.neo4j.unsafe)。batchinsert.internal.BatchInserterImpl.getNodeProperties(BatchInserterImpl.java:900) at org.hucompute.wikidragon.core.test.BatchInserterTest$ReadThread.run(BatchInserterTest.java:56)

谨致问候,

吕迪格

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41628790

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档