2

我是一项名为 Endorphin 的服务的联合创始人,该服务使用 neo4j 存储社交图数据。我们有一个问题。

我们认为改进查询将解决问题,但事实证明这不是数据库失败的原因,因为有时它会成功返回,有时会失败SyntaxException。我们看不出造成这种情况的原因。通过 API 发送查询会导致查询的非系统性失败,而当我们使用控制台发送相同的查询时,它们工作得很好。

细节:

Neo4j 版本为 1.9.2

我们使用的是 Windows Azure,操作系统 Ubuntu 12.04LTS,在 JDK7 中运行

系统配置为 AMD Opteron(tm) 处理器 4171 HE 8 核 cpu,内存 14GB,HDD 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# 来执行查询。它们不会通过控制台失败,但在使用此驱动程序执行时会随机失败。

4

2 回答 2

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

在参数中使用:

{CreatedTime:635094700950000000}
于 2013-08-09T17:13:23.293 回答
0

作为参考,此问题将跟踪此问题的进度/发现:https ://github.com/neo4j/neo4j/issues/1040

于 2013-08-21T12:25:24.107 回答