トランザクションNeo4jRESTAPIを使用してノードを並行して削除および作成する場合のNeo.ClientError.Statement.EntityNotFound

Yevhenii Dermenzhii

トランザクションRESTAPIと自動コミットモードを並行して使用してNeo4jデータベース(v2.1.6、Ubuntu)でノードを削除してから作成すると、次のようなエラーが発生します

{"results":[],"errors":[{"code":"Neo.ClientError.Statement.EntityNotFound","message":"Node with id 35275"}]}

ノードごとにクエリを実行します。

curl -X POST -d @data http://localhost:7474/db/data/transaction/commit -H "Content-Type:application/json; charset=UTF-8" -H Accept:application/json  >out$i  

次のステートメントで

{
    "statements": [
    {
        "statement": "MATCH (k:Keyword {kwId: \"1\"}) DELETE k",
        "parameters": {}
    },
    {
        "statement": "CREATE (k:Keyword {props}) RETURN k",
        "parameters": {
            "props": {
                "kwId": "1"
            }
        }
    }
    ]
}

kwId値は、クエリごとに異なります。

クエリを順番に実行すると、すべて問題ありません

クエリを並行して実行すると、一部のクエリでエラー応答が返されます(20クエリで最大5つのエラー応答)

{"results":[],"errors":[{"code":"Neo.ClientError.Statement.EntityNotFound","message":"Node with id 35275"}]}

これはNeo4jの問題ですか、それとも間違って使用していますか?

問題を再現するスクリプト:

#!/bin/bash
NEO4J_URL=http://localhost:7474
TOTAL_QUERIES=20

# Create temp JSON files tmp1.json, tmp2.json, ....
for (( i=1; i<$TOTAL_QUERIES; i++ ))
do
  JSON=tmp$i.json
  cat > $JSON << END_OF_JSON
{
    "statements": [
    {
            "statement": "MATCH (k:Keyword {kwId: \"$i\"}) DELETE k",
            "parameters": {}
    },
        {
            "statement": "CREATE (k:Keyword {props}) RETURN k",
            "parameters": {
                "props": {
                    "kwId": "$i"
                }
            }
        }
    ]
}
END_OF_JSON
done

for (( i=1; i<$TOTAL_QUERIES; i++ ))
do
  JSON=tmp$i.json
  if [ "$1" = "sync" ]; then
    curl --silent -X POST -d @$JSON $NEO4J_URL/db/data/transaction/commit -H "Content-Type:application/json; charset=UTF-8" -H Accept:application/json  >out$i  
  else
    curl --silent -X POST -d @$JSON $NEO4J_URL/db/data/transaction/commit -H "Content-Type:application/json; charset=UTF-8" -H Accept:application/json  >out$i &
  fi
done

wait
awk 'FNR==1{print ""}1' out* > result
grep "\"errors\":\[.*\]" result
rm out* tmp*.json result

更新:レガシーREST APIを使用すると、エラーメッセージが改善されます

  "message" : "Node with id 35970",
  "exception" : "EntityNotFoundException",
  "fullname" : "org.neo4j.cypher.EntityNotFoundException",
  "stacktrace" : [ "org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext$NodeOperations.getById(TransactionBoundQueryContext.scala:160)", "org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext$$anonfun$getNodesByLabel$1.apply(TransactionBoundQueryContext.scala:135)", "org.neo4j.cypher.internal.spi.v2_1.TransactionBoundQueryContext$$anonfun$getNodesByLabel$1.apply(TransactionBoundQueryContext.scala:135)", "org.neo4j.cypher.internal.helpers.JavaConversionSupport$$anon$2.next(JavaConversionSupport.scala:33)", "scala.collection.Iterator$$anon$11.next(Iterator.scala:328)", "scala.collection.Iterator$$anon$13.next(Iterator.scala:372)", "scala.collection.Iterator$$anon$14.hasNext(Iterator.scala:389)", "scala.collection.Iterator$class.foreach(Iterator.scala:727)", "scala.collection.AbstractIterator.foreach(Iterator.scala:1157)", "scala.collection.generic.Growable$class.$plus$plus$eq(Growable.scala:48)", "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:176)", "scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:45)", "scala.collection.TraversableOnce$class.to(TraversableOnce.scala:273)", "scala.collection.AbstractIterator.to(Iterator.scala:1157)", "scala.collection.TraversableOnce$class.toList(TraversableOnce.scala:257)", "scala.collection.AbstractIterator.toList(Iterator.scala:1157)", "org.neo4j.cypher.internal.compiler.v2_1.pipes.EagerPipe.internalCreateResults(EagerPipe.scala:32)", "org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:105)", "org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:102)", "org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:102)", "org.neo4j.cypher.internal.compiler.v2_1.pipes.PipeWithSource.createResults(Pipe.scala:102)", "org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1$$anonfun$apply$2.apply(ExecutionPlanBuilder.scala:120)", "org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1$$anonfun$apply$2.apply(ExecutionPlanBuilder.scala:119)", "org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionWorkflowBuilder.runWithQueryState(ExecutionPlanBuilder.scala:168)", "org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:118)", "org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anonfun$getExecutionPlanFunction$1.apply(ExecutionPlanBuilder.scala:103)", "org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anon$1.execute(ExecutionPlanBuilder.scala:68)", "org.neo4j.cypher.internal.compiler.v2_1.executionplan.ExecutionPlanBuilder$$anon$1.execute(ExecutionPlanBuilder.scala:67)", "org.neo4j.cypher.internal.ExecutionPlanWrapperForV2_1.execute(CypherCompiler.scala:159)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:76)", "org.neo4j.cypher.ExecutionEngine.execute(ExecutionEngine.scala:71)", "org.neo4j.cypher.javacompat.ExecutionEngine.execute(ExecutionEngine.java:84)", "org.neo4j.server.rest.web.CypherService.cypher(CypherService.java:114)", "java.lang.reflect.Method.invoke(Method.java:606)", "org.neo4j.server.rest.transactional.TransactionalRequestDispatcher.dispatch(TransactionalRequestDispatcher.java:139)", "java.lang.Thread.run(Thread.java:745)" ],
Yevhenii Dermenzhii

プロパティkwIdに新しいインデックスを作成すると、私の場合のエラーが修正されるようです

CREATE INDEX ON :Keyword(kwId)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

Related 関連記事

ホットタグ

アーカイブ