I've built a graph using Neo4j which consists of about 1000 nodes and about 270,000 relationships. The graph is a flight network (airports are nodes, and flights are relationships) so there are many relationships from node to node. I'm sure there are also many cycles in certain queries (I'm not sure if that's a problem). Anyway, certain queries work fine, like these:
我用Neo4j构建了一个图表,它包含了大约1000个节点和大约27万个关系。图是一个飞行网络(机场是节点,航班是关系),所以从节点到节点有很多关系。我确信在某些查询中也有很多循环(我不确定这是不是一个问题)。无论如何,某些查询工作正常,比如:
start a=node(1), b=node(2) match p=a-[:flys_to*..1]->b return p;
start a=node(1), b=node(2) match p=shortestPath(a-[:flys_to]->b) return p;
But when I try other more complicated queries, there is no friendly error message; it just hangs for about 3 minutes (depending on which two nodes I search between) and returns "Undefined".
但是当我尝试其他更复杂的查询时,没有友好的错误消息;它只挂大约3分钟(取决于我搜索的两个节点)和返回“未定义”。
One of the queries that hangs looks like this:
其中一个查询是这样的:
start a=node(1), b=node(2) match p=a-[:flys_to*..2]->b return p;
Also, an interesting side note is that when I type the following query, it instantly returns "Undefined":
另外,有趣的一点是,当我键入下面的查询时,它会立即返回“未定义”:
start a=node(1), b=node(2) match p=a-[:flys_to]->b return p;
Does this make sense, or does anyone have any ideas as to where I might start troubleshooting?
这有意义吗,或者有没有人知道我可能在哪里开始故障排除?
More Info about this Specific Problem
更多关于这个具体问题的信息。
Here's a compressed file of the database: http://www.opensourcebanking.org/neo4j/
这里是数据库的压缩文件:http://www.opensourcebanking.org/neo4j/。
I'm running this in a virtual environment over VMware. The host is OSX 10.8.2 and the guest is Windows Server 2012. The JRE is 1.6.0_38. Also, I have auto indexing setup on the node property 'iata', and the relationship property "flys_to".
我在虚拟环境中运行VMware。主机是OSX 10.8.2,客户是Windows Server 2012。1.6.0_38 JRE。此外,我还在节点属性“iata”上设置了自动索引设置,以及关系属性“flys_to”。
Here are a few Cypher queries and their related logged messages:
下面是一些Cypher查询及其相关的日志消息:
The following query returns 'undefined' almost immediately:
下面的查询几乎立即返回“未定义”:
start a=node(353), b=node(295)
match p=a-->b
return p;
And here's what I get in the log:
这是我在日志里看到的:
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
org.neo4j.helpers.ThisShouldNotHappenError: Developer: Andres claims that: Unexpected traversal state encountered
at org.neo4j.cypher.internal.pipes.matching.BidirectionalTraversalMatcher$StepCollisionDetector.includePath(BidirectionalTraversalMatcher.scala:101)
at org.neo4j.kernel.StandardBranchCollisionDetector.evaluate(StandardBranchCollisionDetector.java:74)
at org.neo4j.kernel.StandardBranchCollisionDetector.evaluate(StandardBranchCollisionDetector.java:37)
at org.neo4j.kernel.impl.traversal.BidirectionalTraverserIterator.fetchNextOrNull(BidirectionalTraverserIterator.java:157)
at org.neo4j.kernel.impl.traversal.BidirectionalTraverserIterator.fetchNextOrNull(BidirectionalTraverserIterator.java:41)
at org.neo4j.helpers.collection.PrefetchingIterator.hasNext(PrefetchingIterator.java:55)
at scala.collection.JavaConversions$JIteratorWrapper.hasNext(JavaConversions.scala:574)
at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:36)
at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:87)
at org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)
at scala.collection.Iterator$class.foreach(Iterator.scala:660)
at org.neo4j.cypher.internal.ClosingIterator.foreach(ClosingIterator.scala:31)
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:128)
at scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:242)
at org.neo4j.cypher.internal.ClosingIterator.toList(ClosingIterator.scala:31)
at org.neo4j.cypher.PipeExecutionResult.createTimedResults(PipeExecutionResult.scala:73)
at org.neo4j.cypher.PipeExecutionResult.dumpToString(PipeExecutionResult.scala:80)
at org.neo4j.cypher.PipeExecutionResult.dumpToString(PipeExecutionResult.scala:125)
at org.neo4j.cypher.javacompat.ExecutionResult.dumpToString(ExecutionResult.java:91)
at org.neo4j.shell.kernel.apps.Start.exec(Start.java:71)
at org.neo4j.shell.kernel.apps.ReadOnlyGraphDatabaseApp.execute(ReadOnlyGraphDatabaseApp.java:32)
at org.neo4j.shell.impl.AbstractAppServer.interpretLine(AbstractAppServer.java:115)
at org.neo4j.shell.kernel.GraphDatabaseShellServer.interpretLine(GraphDatabaseShellServer.java:92)
at org.neo4j.shell.impl.AbstractClient.evaluate(AbstractClient.java:130)
at org.neo4j.shell.impl.AbstractClient.evaluate(AbstractClient.java:114)
at org.neo4j.server.webadmin.console.ShellSession.evaluate(ShellSession.java:101)
at org.neo4j.server.webadmin.rest.console.ConsoleService.exec(ConsoleService.java:125)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.sun.jersey.spi.container.JavaMethodInvokerFactory$1.invoke(JavaMethodInvokerFactory.java:60)
at com.sun.jersey.server.impl.model.method.dispatch.AbstractResourceMethodDispatchProvider$ResponseOutInvoker._dispatch(AbstractResourceMethodDispatchProvider.java:205)
at com.sun.jersey.server.impl.model.method.dispatch.ResourceJavaMethodDispatcher.dispatch(ResourceJavaMethodDispatcher.java:75)
at com.sun.jersey.server.impl.uri.rules.HttpMethodRule.accept(HttpMethodRule.java:288)
at com.sun.jersey.server.impl.uri.rules.ResourceClassRule.accept(ResourceClassRule.java:108)
at com.sun.jersey.server.impl.uri.rules.RightHandPathRule.accept(RightHandPathRule.java:147)
at com.sun.jersey.server.impl.uri.rules.RootResourceClassesRule.accept(RootResourceClassesRule.java:84)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1469)
at com.sun.jersey.server.impl.application.WebApplicationImpl._handleRequest(WebApplicationImpl.java:1400)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1349)
at com.sun.jersey.server.impl.application.WebApplicationImpl.handleRequest(WebApplicationImpl.java:1339)
at com.sun.jersey.spi.container.servlet.WebComponent.service(WebComponent.java:416)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:537)
at com.sun.jersey.spi.container.servlet.ServletContainer.service(ServletContainer.java:699)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:390)
at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:182)
at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
at org.mortbay.jetty.Server.handle(Server.java:326)
at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:943)
at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:410)
at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
The following query works fine. It returns 426 rows and nothing is logged.
以下查询工作正常。它返回426行,没有日志记录。
start a=node(353), b=node(295)
match p=a-[:flys_to*..1]->b
return p;
The following query returns 'undefined' after about 10-15 minutes:
以下查询在10-15分钟后返回“未定义”:
start a=node(353), b=node(295)
match p=a-[:flys_to*..2]->b
return p;
Log:
日志:
SEVERE: The exception contained within MappableContainerException could not be mapped to a response, re-throwing to the HTTP container
java.lang.OutOfMemoryError: Java heap space
at org.neo4j.cypher.internal.pipes.matching.AddedHistory.toSeq(History.scala:87)
at org.neo4j.cypher.internal.pipes.matching.AddedHistory.toMap(History.scala:75)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.isMatchSoFar(PatternMatcher.scala:166)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.org$neo4j$cypher$internal$pipes$matching$PatternMatcher$$traverseNextNodeFromRelationship(PatternMatcher.scala:98)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher$$anonfun$4.apply(PatternMatcher.scala:150)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher$$anonfun$4.apply(PatternMatcher.scala:150)
at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:175)
at scala.collection.immutable.Stream$$anonfun$map$1.apply(Stream.scala:175)
at scala.collection.immutable.Stream$Cons.tail(Stream.scala:634)
at scala.collection.immutable.Stream$Cons.tail(Stream.scala:626)
at scala.collection.immutable.Stream.foldLeft(Stream.scala:302)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.traverseRelationship(PatternMatcher.scala:150)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.traverseNextSpecificNode(PatternMatcher.scala:61)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.traverseNode(PatternMatcher.scala:72)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.foreach(PatternMatcher.scala:36)
at scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)
at scala.collection.mutable.ArrayBuffer.$plus$plus$eq(ArrayBuffer.scala:99)
at scala.collection.TraversableOnce$class.toBuffer(TraversableOnce.scala:250)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.toBuffer(PatternMatcher.scala:28)
at scala.collection.TraversableLike$class.toStream(TraversableLike.scala:571)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.toStream(PatternMatcher.scala:28)
at scala.collection.TraversableLike$class.toIterator(TraversableLike.scala:570)
at org.neo4j.cypher.internal.pipes.matching.PatternMatcher.toIterator(PatternMatcher.scala:28)
at scala.collection.Iterator$$anon$21.hasNext(Iterator.scala:371)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at scala.collection.Iterator$$anon$19.hasNext(Iterator.scala:334)
at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply$mcZ$sp(ClosingIterator.scala:36)
at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
at org.neo4j.cypher.internal.ClosingIterator$$anonfun$hasNext$1.apply(ClosingIterator.scala:35)
at org.neo4j.cypher.internal.ClosingIterator.failIfThrows(ClosingIterator.scala:87)
at org.neo4j.cypher.internal.ClosingIterator.hasNext(ClosingIterator.scala:35)
2 个解决方案
#1
0
Did you try to use shortestPath
or allShortestPaths
for your queries?
您是否尝试使用shortestPath或allShortestPaths来查询您的查询?
start a=node(1), b=node(2) match p=allShortestPaths(a-[:flys_to*..2]->b) return p;
+--------------------------------------------------------------------------------------------------------+
| p |
+--------------------------------------------------------------------------------------------------------+
| [Node[1]{iata:"ABE"},:flys_to[224044] {},Node[546]{iata:"SFO"},:flys_to[24211] {},Node[2]{iata:"ABI"}] |
| [Node[1]{iata:"ABE"},:flys_to[224044] {},Node[546]{iata:"SFO"},:flys_to[24210] {},Node[2]{iata:"ABI"}] |
....
| [Node[1]{iata:"ABE"},:flys_to[66032] {},Node[146]{iata:"DFW"},:flys_to[1] {},Node[2]{iata:"ABI"}] |
| [Node[1]{iata:"ABE"},:flys_to[66032] {},Node[146]{iata:"DFW"},:flys_to[0] {},Node[2]{iata:"ABI"}] |
+--------------------------------------------------------------------------------------------------------+
28 rows
20 ms
start a=node(1), b=node(2) match p=shortestPath(a-[:flys_to*..2]->b) return p;
+--------------------------------------------------------------------------------------------------------+
| p |
+--------------------------------------------------------------------------------------------------------+
| [Node[1]{iata:"ABE"},:flys_to[224044] {},Node[546]{iata:"SFO"},:flys_to[24211] {},Node[2]{iata:"ABI"}] |
+--------------------------------------------------------------------------------------------------------+
1 row
1 ms
#2
0
For me this returns 426 rows:
对我来说,它返回426行:
start a=node(353), b=node(295)
match p=a-->b
return p;
#1
0
Did you try to use shortestPath
or allShortestPaths
for your queries?
您是否尝试使用shortestPath或allShortestPaths来查询您的查询?
start a=node(1), b=node(2) match p=allShortestPaths(a-[:flys_to*..2]->b) return p;
+--------------------------------------------------------------------------------------------------------+
| p |
+--------------------------------------------------------------------------------------------------------+
| [Node[1]{iata:"ABE"},:flys_to[224044] {},Node[546]{iata:"SFO"},:flys_to[24211] {},Node[2]{iata:"ABI"}] |
| [Node[1]{iata:"ABE"},:flys_to[224044] {},Node[546]{iata:"SFO"},:flys_to[24210] {},Node[2]{iata:"ABI"}] |
....
| [Node[1]{iata:"ABE"},:flys_to[66032] {},Node[146]{iata:"DFW"},:flys_to[1] {},Node[2]{iata:"ABI"}] |
| [Node[1]{iata:"ABE"},:flys_to[66032] {},Node[146]{iata:"DFW"},:flys_to[0] {},Node[2]{iata:"ABI"}] |
+--------------------------------------------------------------------------------------------------------+
28 rows
20 ms
start a=node(1), b=node(2) match p=shortestPath(a-[:flys_to*..2]->b) return p;
+--------------------------------------------------------------------------------------------------------+
| p |
+--------------------------------------------------------------------------------------------------------+
| [Node[1]{iata:"ABE"},:flys_to[224044] {},Node[546]{iata:"SFO"},:flys_to[24211] {},Node[2]{iata:"ABI"}] |
+--------------------------------------------------------------------------------------------------------+
1 row
1 ms
#2
0
For me this returns 426 rows:
对我来说,它返回426行:
start a=node(353), b=node(295)
match p=a-->b
return p;