CreateRelationShipTo 挂起并且以前保存的节点太少

CreateRelationShipTo hangs and previously Saved NOdes too missing

我遇到了一个独特的问题。我们正在使用 bojo 方法为节点设置属性。设置属性后,我们正在创建与已创建节点的关系。第一次创建节点和关系船时,当我保存另一个节点时,它挂在 CreateRelationShipTo 行上并且之前保存的节点在 Neo4j 中丢失了吗?任何人都可以指导我们为什么会这样吗?抱歉没有提供正确的信息。 Java代码如下:

Transaction trx = DataSource.getGraphDBAPI().beginTx();  
try{
    Node apiDetailsNode = DataSource.getGraphDB().createNode();  
    apiDetailsNode.setId("1");  
    apiDetailsNode.setName("Test API");  
    apiDetailsNode.setURL("www.test.com");  
    parentNode.createRelationshipTo(apiDetailsNode,        
    KnoxxiRelationshipType.API);  
    apiDetailsNode.setStatus("1");
    trx.success();
}catch (Exception e) {
    trx.failure();
    log.error("Strange API Failed To Create");
} finally {trx.finish();} 

neo4j配置如下:

node_auto_indexing=true
cache_type=gcr
nodestore_propertystore_mapped_memory_size=150M
nodestore_mapped_memory_size=100M
relationshipstore_mapped_memory_size=500M
strings_mapped_memory_size=150M
nodestore_mapped_memory_size=150M
relationship_auto_indexing=true

现在我们的数据存储中有 200 万个节点和 800 万个关系。

我们正在使用 1.9.8 Neo4j 版本

message.log 文件的最后 20 行如下:

2015-03-20 09:25:08.030+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 385ms [total block time: 5.365s]
2015-03-20 09:25:25.766+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 395ms [total block time: 5.76s]
2015-03-20 09:25:44.909+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 415ms [total block time: 6.175s]
2015-03-20 09:28:46.736+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 377ms [total block time: 6.552s]
2015-03-20 09:28:50.147+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 395ms [total block time: 6.947s]
2015-03-20 09:31:17.876+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 525ms [total block time: 7.472s]
2015-03-20 09:32:50.150+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 424ms [total block time: 7.896s]
2015-03-20 09:35:03.267+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 498ms [total block time: 8.394s]
2015-03-20 09:35:14.967+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 417ms [total block time: 8.811s]
2015-03-20 09:35:20.184+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 402ms [total block time: 9.213s]
2015-03-20 09:37:03.175+0000 INFO  [o.n.k.EmbeddedGraphDatabase]: GC Monitor: Application threads blocked for an additional 415ms [total block time: 9.628s]

我已找到问题的根本原因并已修复。挂起的原因是由于 Open Transaction 连接。(可以通过 JMX 控制台找到)。

由于在执行密码查询后没有关闭执行结果,所以发生了打开的连接。示例代码如下,

public static Node executeCypherQuerySingleResult(String strCypherQuery, String strResultColumnName) {
    ExecutionResult result = null;
    Iterator<Node> n_column = null;
    ExecutionEngine engine = null;

    try {

        engine = NeoDbConnection.getExecutionEngine(); // This will return the Execution Engine Instance from Neo DB Connection Singleton Class 
        result = engine.execute(strCypherQuery);
        n_column = result.columnAs(strResultColumnName);
        while (n_column.hasNext()) {
            Node node = n_column.next();
            return node;
        }
    } catch (Exception e) {
        log.warn("Exception on Executing Cypher Query : " + strCypherQuery + ".. Error is : " + e.getLocalizedMessage());
    } finally {
        // 
        if (null != result) {
            result.close(); // After I add this the issue was solved
        }
        result = null;
        n_column = null;
        engine = null;
    }
    return null;
}

感谢所有指导解决问题的人。