我是一个名为Endorphin的服务的联合创始人,该服务使用neo4j来存储社交图数据。我们遇到了问题。
我们认为改进查询将解决问题,但事实证明这不是数据库失败的原因,因为有时它会成功返回,有时会因SyntaxException
而失败。我们无法看到导致这种情况发生的原因。通过API发送查询会导致查询失败,而当我们使用控制台发送相同的查询时,它们可以很好地工作。
详细说明:
Neo4j版本是1.9.2
我们正在使用Windows Azure,OS Ubuntu 12.04LTS,在JDK7中运行
系统配置是AMD Opteron(tm)处理器4171 HE 8核心CPU,内存14GB,硬盘250 GB + 1TB,数据库大小为1GB。缓存配置如下:
cache_type=gcr
use_memory_mapped_buffers=true
neostore.nodestore.db.mapped_memory=1024M
neostore.relationshipstore.db.mapped_memory=1024M
neostore.propertystore.db.mapped_memory=2048M
neostore.propertystore.db.strings.mapped_memory=1024M
neostore.propertystore.db.arrays.mapped_memory=1024M
我附上了查询和错误的示例:
查询是:
start n=node(1341474), oldFriend0 = node(21103),
oldFriend1 = node(21103), oldFriend2 = node(302)
create unique n<-[:Comment{CreatedTime:635082180250000000}]-oldFriend0
create unique n<-[:Comment{CreatedTime:635082713870000000}]-oldFriend1
create unique n<-[:Comment{CreatedTime:635082527270000000}]-oldFriend2
return 1.0 as Val
响应状态为:400 Bad Request
Neo4j的回复(可能包含有用的细节!)是:
{"message" : "Can't create UNNAMED1 with properties here.
It already exists in this context", "exception" : "SyntaxException", "fullname" : "org.neo4j.cypher.SyntaxException", "stacktrace" :
[ "org.neo4j.cypher.internal.pipes.ExecuteUpdateCommandsPipe$$anonfun$assertNothingIsCreatedWhenItShouldNot$1.apply(ExecuteUpdateCommandsPipe.scala:83)",
"org.neo4j.cypher.internal.pipes.ExecuteUpdateCommandsPipe$$anonfun$assertNothingIsCreatedWhenItShouldNot$1.apply(ExecuteUpdateCommandsPipe.scala:82)",
"scala.collection.immutable.Stream.foreach(Stream.scala:547)",
"org.neo4j.cypher.internal.pipes.ExecuteUpdateCommandsPipe.assertNothingIsCreatedWhenItShouldNot(ExecuteUpdateCommandsPipe.scala
又一个例子:
查询是:
start n=node(1398749), oldFriend0 = node(6856), oldFriend1 = node(6856),
oldFriend2 = node(6848), oldFriend3 = node(6848), oldFriend4 = node(6848),
oldFriend5 = node(5600), oldFriend6 = node(7245), oldFriend7 = node(223),
oldFriend8 = node(223), oldFriend9 = node(223), oldFriend10 = node(223),
oldFriend11 = node(223), oldFriend12 = node(223), oldFriend13 = node(223),
oldFriend14 = node(223), oldFriend15 = node(7821), oldFriend16 = node(126899),
oldFriend17 = node(7133), oldFriend18 = node(7133), oldFriend19 = node(6844),
oldFriend20 = node(6915) create unique n<-[:Comment{CreatedTime:635094700950000000}]-oldFriend0 create unique n<-[:Comment{CreatedTime:635094783870000000}]-oldFriend1
create unique n<-[:Comment{CreatedTime:635094735780000000}]-oldFriend2
create unique n<-[:Comment{CreatedTime:635094744040000000}]-oldFriend3
create unique n<-[:Comment{CreatedTime:635094744310000000}]-oldFriend4
create unique n<-[:Comment{CreatedTime:635094776820000000}]-oldFriend5
create unique n<-[:Comment{CreatedTime:635094730830000000}]-oldFriend6
create unique n<-[:Comment{CreatedTime:635094731200000000}]-oldFriend7
create unique n<-[:Comment{CreatedTime:635094742500000000}]-oldFriend8
create unique n<-[:Comment{CreatedTime:635094742990000000}]-oldFriend9
create unique n<-[:Comment{CreatedTime:635094743440000000}]-oldFriend10
create unique n<-[:Comment{CreatedTime:635094743840000000}]-oldFriend11
create unique n<-[:Comment{CreatedTime:635094744640000000}]-oldFriend12
create unique n<-[:Comment{CreatedTime:635094749740000000}]-oldFriend13
create unique n<-[:Comment{CreatedTime:635094826130000000}]-oldFriend14
create unique n<-[:Comment{CreatedTime:635094748250000000}]-oldFriend15
create unique n<-[:Comment{CreatedTime:635094708340000000}]-oldFriend16
create unique n<-[:Comment{CreatedTime:635094742320000000}]-oldFriend17
create unique n<-[:Comment{CreatedTime:635094742770000000}]-oldFriend18
create unique n<-[:Comment{CreatedTime:635094692580000000}]-oldFriend19
create unique n<-[:Comment{CreatedTime:635094743430000000}]-oldFriend20
return 1.0 as Val
响应状态为:400 Bad Request
The response from Neo4j (which might include useful detail!) was:
{ "message" : "Can't create UNNAMED1 with properties here.
It already exists in this context", "exception" : "SyntaxException",
"fullname" : "org.neo4j.cypher.SyntaxException",
"stacktrace" : [ "org.neo4j.cypher.internal.pipes.ExecuteUpdateCommandsPipe$$anonfun$assertNothingIsCreatedWhenItShouldNot$1.apply(ExecuteUpdateCommandsPipe.scala:83)",
"org.neo4j.cypher.internal.pipes.ExecuteUpdateCommandsPipe$$anonfun$assertNothingIsCreatedWhenItShouldNot$1.apply(ExecuteUpdateCommandsPipe.scala:82)",
"scala.collection.immutable.Stream.foreach(Stream.scala:547)"
感谢任何帮助。提前谢谢。
UPD :我们正在使用Neo4jClient for C#来执行查询。它们不会通过控制台失败,但是当使用此驱动程序执行时它们会随机失败。
答案 0 :(得分:1)
我会尝试一些可能有用的东西。
您是否尝试过发送一批单独的声明? 请参阅:http://docs.neo4j.org/chunked/stable/rest-api-batch-ops.html
通过这种方式,您可以对其进行参数化,并立即将它们全部发送出去:
start n=node({destId}), oldFriend=node({oldFriend})
create unique n<-[:Comment {relProps}]-oldFriend
在params中使用:
{CreatedTime:635094700950000000}
答案 1 :(得分:0)
作为参考,此问题将跟踪此问题的进度/结果:https://github.com/neo4j/neo4j/issues/1040