Neo4j查询错误地返回null

时间:2018-09-11 08:56:43

标签: neo4j cypher

我在Docker上使用Neo4j v 3.4.1

我通过cyshell运行以下查询

MATCH (blogA:content {entitySubType:"blog"})-[]->(t:term)<-[]-(blogB:content {entitySubType:"blog"})
WHERE blogA <> blogB 
RETURN ID(blogA), ID(blogB), count(t);

查询在几个小时后返回null。我无法理解或找到任何指向我解决方案的东西。检查调试日志时,我得到以下信息:

2018-09-08 09:53:54.675+0000 ERROR [o.n.b.v.r.ErrorReporter] Client triggered an unexpected error [Neo.DatabaseError.General.UnknownError]: null, reference 549a05ea-3bee-442b-baf5-fd741d37e2db.
2018-09-08 09:53:54.675+0000 ERROR [o.n.b.v.r.ErrorReporter] Client triggered an unexpected error [Neo.DatabaseError.General.UnknownError]: null, reference 549a05ea-3bee-442b-baf5-fd741d37e2db.
java.lang.NegativeArraySizeException
        at scala.collection.mutable.HashTable$class.resize(HashTable.scala:257)
        at scala.collection.mutable.HashTable$class.scala$collection$mutable$HashTable$$addEntry0(HashTable.scala:157)
        at scala.collection.mutable.HashTable$class.addEntry(HashTable.scala:148)
        at scala.collection.mutable.HashMap.addEntry(HashMap.scala:40)
        at scala.collection.mutable.HashMap.addEntry(HashMap.scala:93)
        at scala.collection.mutable.HashMap.getOrElseUpdate(HashMap.scala:79)
        at org.neo4j.cypher.internal.runtime.interpreted.pipes.EagerAggregationPipe$$anonfun$internalCreateResults$1.apply(EagerAggregationPipe.scala:120)
        at org.neo4j.cypher.internal.runtime.interpreted.pipes.EagerAggregationPipe$$anonfun$internalCreateResults$1.apply(EagerAggregationPipe.scala:118)
        at scala.collection.Iterator$class.foreach(Iterator.scala:891)
        at scala.collection.AbstractIterator.foreach(Iterator.scala:1334)
        at org.neo4j.cypher.internal.runtime.interpreted.pipes.EagerAggregationPipe.internalCreateResults(EagerAggregationPipe.scala:118)
        at org.neo4j.cypher.internal.runtime.interpreted.pipes.PipeWithSource.createResults(Pipe.scala:76)
        at org.neo4j.cypher.internal.runtime.interpreted.pipes.PipeWithSource.createResults(Pipe.scala:72)
        at org.neo4j.cypher.internal.compatibility.v3_4.runtime.executionplan.BaseExecutionResultBuilderFactory$BaseExecutionWorkflowBuilder.createResults(DefaultExecutionResultBuilderFactory.scala:105)
        at org.neo4j.cypher.internal.compatibility.v3_4.runtime.executionplan.BaseExecutionResultBuilderFactory$BaseExecutionWorkflowBuilder.build(DefaultExecutionResultBuilderFactory.scala:77)
        at org.neo4j.cypher.internal.compatibility.v3_4.runtime.BuildInterpretedExecutionPlan$$anonfun$getExecutionPlanFunction$1.apply(BuildInterpretedExecutionPlan.scala:97)
        at org.neo4j.cypher.internal.compatibility.v3_4.runtime.BuildInterpretedExecutionPlan$$anonfun$getExecutionPlanFunction$1.apply(BuildInterpretedExecutionPlan.scala:80)
        at org.neo4j.cypher.internal.compatibility.v3_4.runtime.BuildInterpretedExecutionPlan$InterpretedExecutionPlan.run(BuildInterpretedExecutionPlan.scala:111)
        at org.neo4j.cypher.internal.compatibility.LatestRuntimeVariablePlannerCompatibility$ExecutionPlanWrapper$$anonfun$run$1.apply(LatestRuntimeVariablePlannerCompatibility.scala:128)
        at org.neo4j.cypher.internal.compatibility.LatestRuntimeVariablePlannerCompatibility$ExecutionPlanWrapper$$anonfun$run$1.apply(LatestRuntimeVariablePlannerCompatibility.scala:124)
        at org.neo4j.cypher.exceptionHandler$runSafely$.apply(exceptionHandler.scala:89)
        at org.neo4j.cypher.internal.compatibility.LatestRuntimeVariablePlannerCompatibility$ExecutionPlanWrapper.run(LatestRuntimeVariablePlannerCompatibility.scala:124)
        at org.neo4j.cypher.internal.PreparedPlanExecution.execute(PreparedPlanExecution.scala:29)
        at org.neo4j.cypher.internal.ExecutionEngine.execute(ExecutionEngine.scala:119)
        at org.neo4j.cypher.internal.javacompat.ExecutionEngine.executeQuery(ExecutionEngine.java:61)
        at org.neo4j.bolt.v1.runtime.TransactionStateMachineSPI$1.start(TransactionStateMachineSPI.java:144)
        at org.neo4j.bolt.v1.runtime.TransactionStateMachine$State.startExecution(TransactionStateMachine.java:444)
        at org.neo4j.bolt.v1.runtime.TransactionStateMachine$State$1.execute(TransactionStateMachine.java:259)
        at org.neo4j.bolt.v1.runtime.TransactionStateMachine$State$1.run(TransactionStateMachine.java:240)
        at org.neo4j.bolt.v1.runtime.TransactionStateMachine.run(TransactionStateMachine.java:81)
        at org.neo4j.bolt.v1.runtime.BoltStateMachine$State$2.run(BoltStateMachine.java:457)
        at org.neo4j.bolt.v1.runtime.BoltStateMachine.run(BoltStateMachine.java:225)
        at org.neo4j.bolt.v1.messaging.BoltMessageRouter.lambda$onRun$3(BoltMessageRouter.java:93)
        at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(DefaultBoltConnection.java:195)
        at org.neo4j.bolt.runtime.DefaultBoltConnection.processNextBatch(DefaultBoltConnection.java:143)
        at org.neo4j.bolt.runtime.ExecutorBoltScheduler.executeBatch(ExecutorBoltScheduler.java:170)
        at org.neo4j.bolt.runtime.ExecutorBoltScheduler.lambda$scheduleBatchOrHandleError$2(ExecutorBoltScheduler.java:153)
        at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)

我们在这里共同假定未为所有内容节点设置entitySubType。我验证这个假设是正确的。基于此,我使用如下形式的exist()谓词函数重新构造了查询:

MATCH (blogA:content)-[:TaggedWith]->(t:term)<-[:TaggedWith]-(blogB:content) 
WHERE ID(blogA) <> ID(blogB) AND exists(blogA.entitySubType) AND 
exists(blogB.entitySubType) AND "blog" = blogA.entitySubType AND "blog" = 
blogB.entitySubType RETURN ID(blogA), ID(blogB), count(t);

查询重新设置为null,并在〜19.1h(比上次时间早3分钟)之后再次以tex异常结束

EXPLAIN命令给出以下查询计划: Query PLan

我看不到哪里存在(blogA.entitySubType)。而且,我找不到过滤器“ blog” = blogA.entitySubType和“ blog” = blogB.entitySubType。

我的查询错误还是查询计划的可视化不完整?

2 个答案:

答案 0 :(得分:1)

听起来它可能是一个为空的属性,也许未在所有帖子上都设置“ entitySubType”?

错误是一致的还是间歇的? 数据库是否持续更新,如果是,如何更新?

答案 1 :(得分:1)

在某些节点中可能未设置属性“ entitySubType”,这就是执行查询执行时将不返回缺少“ entitySubType”的节点的原因。确保所有节点都包含entitySubType属性。