通过Rest更新Neo4J中的节点时出错

时间:2013-08-16 16:55:48

标签: neo4j

我们有一个Neo4J测试数据库,大约有250万个节点。我们正在尝试更新每个节点以包含一些其他属性。为此,我们使用REST API依次更新每个节点。

在此过程的大约一半时间,我们收到服务器的内存不足错误响应,并在REST响应中返回以下堆栈跟踪:


    {
      "message" : "java.io.IOException: Map failed",
      "exception" : "RuntimeException",
      "fullname" : "java.lang.RuntimeException",
      "stacktrace" : [
    "org.neo4j.index.impl.lucene.LuceneDataSource.refreshSearcher(LuceneDataSource.java:514)",
    "org.neo4j.index.impl.lucene.LuceneDataSource.refreshSearcherIfNeeded(LuceneDataSource.java:631)", 
    "org.neo4j.index.impl.lucene.LuceneDataSource.getIndexSearcher(LuceneDataSource.java:575)",
    "org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:268)", "org.neo4j.index.impl.lucene.LuceneIndex.get(LuceneIndex.java:207)",
    "org.neo4j.kernel.AbstractAutoIndexerImpl$ReadOnlyIndexToIndexAdapter.get(AbstractAutoIndexerImpl.java:236)",
    "org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.indexGet(GDSBackedQueryContext.scala:84)",
    "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$1.apply(IndexQueryBuilder.scala:76)",
    "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$1.apply(IndexQueryBuilder.scala:73)",
    "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:36)",
    "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:35)", 
    "scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)",
    "scala.collection.Iterator$class.foreach(Iterator.scala:727)",
    "scala.collection.AbstractIterator.foreach(Iterator.scala:1156)", 
    "scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)",
    "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:178)",
    "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)",
    "scala.collection.TraversableOnce$class.to(TraversableOnce.scala:259)",
    "scala.collection.AbstractIterator.to(Iterator.scala:1156)", 
    "scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:243)", 
    "scala.collection.AbstractIterator.toList(Iterator.scala:1156)", 
    "org.neo4j.cypher.internal.pipes.EagerPipe.internalCreateResults(EagerPipe.scala:35)",
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:69)",
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.org$neo4j$cypher$internal$executionplan$ExecutionPlanImpl$$prepareStateAndResult(ExecutionPlanImpl.scala:164)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:146)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:145)",
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:38)", 
    "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:72)",
    "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:76)", 
    "org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)", 
    "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:94)", 
    "java.lang.reflect.Method.invoke(Method.java:606)", 
    "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)", 
    "org.neo4j.server.extension.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:57)" 

    ],
      "cause" : {
        "message" : "Map failed",
        "cause" : {
          "message" : "Map failed",
          "exception" : "OutOfMemoryError",
          "stacktrace" : [ 
    "sun.nio.ch.FileChannelImpl.map0(Native Method)", 
    "sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:846)", 
    "org.apache.lucene.store.MMapDirectory$MMapIndexInput.(MMapDirectory.java:270)",
    "org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:220)", 
    "org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:345)", 
    "org.apache.lucene.index.CompoundFileWriter.copyFile(CompoundFileWriter.java:231)", 
    "org.apache.lucene.index.CompoundFileWriter.close(CompoundFileWriter.java:201)", 
    "org.apache.lucene.index.DocumentsWriter.flush(DocumentsWriter.java:604)", 
    "org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3587)", 
    "org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3552)", 
    "org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:450)", 
    "org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:399)", 
    "org.apache.lucene.index.DirectoryReader.doOpenFromWriter(DirectoryReader.java:413)", 
    "org.apache.lucene.index.DirectoryReader.doOpenIfChanged(DirectoryReader.java:432)", 
    "org.apache.lucene.index.DirectoryReader.doOpenIfChanged(DirectoryReader.java:375)", 
    "org.apache.lucene.index.DirectoryReader.doOpenIfChanged(DirectoryReader.java:392)", 
    "org.apache.lucene.index.IndexReader.openIfChanged(IndexReader.java:634)", 
    "org.neo4j.index.impl.lucene.LuceneDataSource.refreshSearcher(LuceneDataSource.java:503)", 
    "org.neo4j.index.impl.lucene.LuceneDataSource.refreshSearcherIfNeeded(LuceneDataSource.java:631)", 
    "org.neo4j.index.impl.lucene.LuceneDataSource.getIndexSearcher(LuceneDataSource.java:575)", 
    "org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:268)", 
    "org.neo4j.index.impl.lucene.LuceneIndex.get(LuceneIndex.java:207)", 
    "org.neo4j.kernel.AbstractAutoIndexerImpl$ReadOnlyIndexToIndexAdapter.get(AbstractAutoIndexerImpl.java:236)", 
    "org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.indexGet(GDSBackedQueryContext.scala:84)", 
    "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$1.apply(IndexQueryBuilder.scala:76)", 
    "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$1.apply(IndexQueryBuilder.scala:73)", 
    "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:36)", 
    "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:35)", "scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)", 
    "scala.collection.Iterator$class.foreach(Iterator.scala:727)", 
    "scala.collection.AbstractIterator.foreach(Iterator.scala:1156)", 
    "scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)", 
    "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:178)", 
    "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)", 
    "scala.collection.TraversableOnce$class.to(TraversableOnce.scala:259)", 
    "scala.collection.AbstractIterator.to(Iterator.scala:1156)", 
    "scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:243)", 
    "scala.collection.AbstractIterator.toList(Iterator.scala:1156)", 
    "org.neo4j.cypher.internal.pipes.EagerPipe.internalCreateResults(EagerPipe.scala:35)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:69)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.org$neo4j$cypher$internal$executionplan$ExecutionPlanImpl$$prepareStateAndResult(ExecutionPlanImpl.scala:164)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:146)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:145)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:38)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:72)", 
    "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:76)", 
    "org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)", 
    "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:94)", 
    "java.lang.reflect.Method.invoke(Method.java:606)", 
    "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)", 
    "org.neo4j.server.extension.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:57)" 
    ],
          "fullname" : "java.lang.OutOfMemoryError"
        },
        "exception" : "IOException",
        "stacktrace" : [ 
    "sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:849)", 
    "org.apache.lucene.store.MMapDirectory$MMapIndexInput.(MMapDirectory.java:270)", 
    "org.apache.lucene.store.MMapDirectory.openInput(MMapDirectory.java:220)", 
    "org.apache.lucene.store.FSDirectory.openInput(FSDirectory.java:345)", 
    "org.apache.lucene.index.CompoundFileWriter.copyFile(CompoundFileWriter.java:231)", 
    "org.apache.lucene.index.CompoundFileWriter.close(CompoundFileWriter.java:201)", 
    "org.apache.lucene.index.DocumentsWriter.flush(DocumentsWriter.java:604)", 
    "org.apache.lucene.index.IndexWriter.doFlush(IndexWriter.java:3587)", 
    "org.apache.lucene.index.IndexWriter.flush(IndexWriter.java:3552)", 
    "org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:450)", 
    "org.apache.lucene.index.IndexWriter.getReader(IndexWriter.java:399)", 
    "org.apache.lucene.index.DirectoryReader.doOpenFromWriter(DirectoryReader.java:413)", 
    "org.apache.lucene.index.DirectoryReader.doOpenIfChanged(DirectoryReader.java:432)", 
    "org.apache.lucene.index.DirectoryReader.doOpenIfChanged(DirectoryReader.java:375)", 
    "org.apache.lucene.index.DirectoryReader.doOpenIfChanged(DirectoryReader.java:392)", 
    "org.apache.lucene.index.IndexReader.openIfChanged(IndexReader.java:634)", 
    "org.neo4j.index.impl.lucene.LuceneDataSource.refreshSearcher(LuceneDataSource.java:503)", 
    "org.neo4j.index.impl.lucene.LuceneDataSource.refreshSearcherIfNeeded(LuceneDataSource.java:631)", 
    "org.neo4j.index.impl.lucene.LuceneDataSource.getIndexSearcher(LuceneDataSource.java:575)", 
    "org.neo4j.index.impl.lucene.LuceneIndex.query(LuceneIndex.java:268)", 
    "org.neo4j.index.impl.lucene.LuceneIndex.get(LuceneIndex.java:207)", 
    "org.neo4j.kernel.AbstractAutoIndexerImpl$ReadOnlyIndexToIndexAdapter.get(AbstractAutoIndexerImpl.java:236)", 
    "org.neo4j.cypher.internal.spi.gdsimpl.GDSBackedQueryContext$$anon$1.indexGet(GDSBackedQueryContext.scala:84)", 
    "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$1.apply(IndexQueryBuilder.scala:76)", 
    "org.neo4j.cypher.internal.executionplan.builders.IndexQueryBuilder$$anonfun$getNodeGetter$1.apply(IndexQueryBuilder.scala:73)", 
    "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:36)", 
    "org.neo4j.cypher.internal.pipes.StartPipe$$anonfun$internalCreateResults$1.apply(StartPipe.scala:35)", 
    "scala.collection.Iterator$$anon$13.hasNext(Iterator.scala:371)", 
    "scala.collection.Iterator$class.foreach(Iterator.scala:727)", 
    "scala.collection.AbstractIterator.foreach(Iterator.scala:1156)", 
    "scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)", 
    "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:178)", 
    "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)", 
    "scala.collection.TraversableOnce$class.to(TraversableOnce.scala:259)", 
    "scala.collection.AbstractIterator.to(Iterator.scala:1156)", 
    "scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:243)", 
    "scala.collection.AbstractIterator.toList(Iterator.scala:1156)", 
    "org.neo4j.cypher.internal.pipes.EagerPipe.internalCreateResults(EagerPipe.scala:35)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:69)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.pipes.PipeWithSource.createResults(Pipe.scala:66)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.org$neo4j$cypher$internal$executionplan$ExecutionPlanImpl$$prepareStateAndResult(ExecutionPlanImpl.scala:164)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:146)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl$$anonfun$6.apply(ExecutionPlanImpl.scala:145)", 
    "org.neo4j.cypher.internal.executionplan.ExecutionPlanImpl.execute(ExecutionPlanImpl.scala:38)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:72)", 
    "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:76)", 
    "org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:79)", 
    "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:94)", 
    "java.lang.reflect.Method.invoke(Method.java:606)", 
    "org.neo4j.server.rest.security.SecurityFilter.doFilter(SecurityFilter.java:112)", 
    "org.neo4j.server.extension.auth.AuthenticationFilter.doFilter(AuthenticationFilter.java:57)" 
    ],
        "fullname" : "java.io.IOException"
      }
    }

我还提供了一个请求内容和标题的示例:


    JSON content:
    {"query":"START myNode=node:node_auto_index(myIndex = {myIndex}) SET myNode.propOne = {propOne}, myNode.propTwo = {propTwo}, myNode.propThree = {propThree}","params":{"propOne":"valueOne","propTwo":"valueTwo","propThree":"valueThree","myIndex":"indexValue"}}

    Request Headers:
    POST /db/data/cypher HTTP/1.1
    Host: localhost:7474
    Accept: application/json
    Content-Type: application/json
    Content-Length:


的Neo4j-wrapper.conf


    wrapper.java.additional=-Dorg.neo4j.server.properties=conf/neo4j-server.properties
    wrapper.java.additional=-Djava.util.logging.config.file=conf/logging.properties
    wrapper.java.additional=-Dlog4j.configuration=file:conf/log4j.properties

    #********************************************************************
    # JVM Parameters
    #********************************************************************

    wrapper.java.additional=-XX:+UseConcMarkSweepGC
    wrapper.java.additional=-XX:+CMSClassUnloadingEnabled

    # Uncomment the following lines to enable garbage collection logging
    #wrapper.java.additional=-Xloggc:data/log/neo4j-gc.log
    #wrapper.java.additional=-XX:+PrintGCDetails
    #wrapper.java.additional=-XX:+PrintGCDateStamps
    #wrapper.java.additional=-XX:+PrintGCApplicationStoppedTime

    # Initial Java Heap Size (in MB)
    wrapper.java.initmemory=2048

    # Maximum Java Heap Size (in MB)
    wrapper.java.maxmemory=8192

    #********************************************************************
    # Wrapper settings
    #********************************************************************
    # Override default pidfile and lockfile 
    #wrapper.pidfile=../data/neo4j-server.pid
    #wrapper.lockfile=../data/neo4j-server.lck

    #********************************************************************
    # Wrapper Windows NT/2000/XP Service Properties
    #********************************************************************
    # WARNING - Do not modify any of these properties when an application
    #  using this configuration file has been installed as a service.
    #  Please uninstall the service before modifying this section.  The
    #  service can then be reinstalled.

    # Name of the service
    wrapper.name=neo4j

    # User account to be used for linux installs. Will default to current
    # user if not set.
    wrapper.user=neo4j

    wrapper.user.created=false

neo4j.properties


    # Default values for the low-level graph engine
    neostore.nodestore.db.mapped_memory=100M
    neostore.relationshipstore.db.mapped_memory=2G
    neostore.propertystore.db.mapped_memory=90M
    neostore.propertystore.db.strings.mapped_memory=250M
    neostore.propertystore.db.arrays.mapped_memory=130M

    # Enable this to be able to upgrade a store from 1.4 -> 1.5 or 1.4 -> 1.6
    #allow_store_upgrade=true

    # Enable this to specify a parser other than the default one. 1.5, 1.6, 1.7 are available
    #cypher_parser_version=1.6

    # Keep logical logs, helps debugging but uses more disk space, enabled for
    # legacy reasons To limit space needed to store historical logs use values such
    # as: "7 days" or "100M size" instead of "true"
    keep_logical_logs=true

    # Autoindexing

    # Enable auto-indexing for nodes, default is false
    node_auto_indexing=true

    # The node property keys to be auto-indexed, if enabled
    node_keys_indexable=user_id,group_id,program_id

    # Enable auto-indexing for relationships, default is false
    #relationship_auto_indexing=true

    # The relationship property keys to be auto-indexed, if enabled
    #relationship_keys_indexable=name,age

请仔细阅读:
我不一定在寻找更新Node属性的替代方法。我实际上非常有信心我们可以很容易地想出一些可以解决这个错误的东西。我发布此问题的目的是为了更好地理解此错误的性质。究竟是什么导致它首先?我希望了解这个错误的原因会更好地帮助我们在生产环境中避免它。

提前谢谢。

0 个答案:

没有答案