<https://lh5.googleusercontent.com/-rbd7LI5Kkb4/VRAhHaRjGmI/AAAAAAAAA00/zv5EihVF9eM/s1600/Node.png>
<https://lh6.googleusercontent.com/--dtQ6XnekOU/VRAhMtBn0dI/AAAAAAAAA08/DwGSvFYyiy4/s1600/RelationshipCache.png> <https://lh5.googleusercontent.com/-3Q8l0zEVwck/VRAhPqo6axI/AAAAAAAAA1E/6kjZC64tKvg/s1600/transactions.png> <https://lh3.googleusercontent.com/-mxFNC-k10d0/VRAhTLESkVI/AAAAAAAAA1M/BWmlFeAepRE/s1600/XA_resource.png> <https://lh4.googleusercontent.com/-XEgYT0sf0iA/VRAgz9L0v5I/AAAAAAAAA0s/ClgLwlioVZk/s1600/Locking.png> Hello Michael, I have modified the code to create only one GraphDatabaseService. Also I have added the Execution Engine to GraphDatabaseService. The issue still exists. I have attached the updated code and also the JMX screenshots. Kindly guide if some issues. =============================================================== public class DataSource { static GraphDatabaseService graphDb = null; static ExecutionEngine executionEngine = null; public static GraphDatabaseService getGraphDBAPI() { return graphDb; } public static ExecutionEngine getExecutionEngine() { return executionEngine; } public static GraphDatabaseService dbStart() { String glassfishInstanceRootPropertyName = "com.sun.aas.instanceRoot"; String serverLocation = System.getProperty(glassfishInstanceRootPropertyName) ; String fileName = serverLocation + "/config/neoDb.conf"; log.info("Database Config File Path : " + fileName); Properties prop = new Properties(); try { // the configuration file name InputStream is = new FileInputStream(fileName); // load the properties file prop.load(is); } catch (IOException e) { log.warn("Exception With Db Setup : " + e.getLocalizedMessage()); } DB_PATH = prop.getProperty("graphdb.location"); DB_EMBED_PORT = prop.getProperty("graphdb.port"); SERVER_HOSTNAME = prop.getProperty("graphdb.server.hostname"); UPLOAD_FILE_LOC = serverLocation + prop.getProperty("upload.dir"); DB_TUNE_FILE = serverLocation+"/config/neo4j.properties"; log.info("Properties File : " + DB_PATH); // Create Database with Properties GraphDatabaseAPI graphdb = (GraphDatabaseAPI) new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_PATH). setConfig(GraphDatabaseSettings.node_keys_indexable, prop.getProperty("node_keys_indexable")). setConfig(GraphDatabaseSettings.node_auto_indexing, prop.getProperty("node_auto_indexing")). setConfig(GraphDatabaseSettings.cache_type, prop.getProperty("cache_type")). setConfig(GraphDatabaseSettings.allow_store_upgrade, prop.getProperty("allow_store_upgrade")). setConfig(GraphDatabaseSettings.nodestore_propertystore_mapped_memory_size, prop.getProperty("nodestore_propertystore_mapped_memory_size")). setConfig(GraphDatabaseSettings.nodestore_mapped_memory_size, prop.getProperty("nodestore_mapped_memory_size")). setConfig(GraphDatabaseSettings.relationshipstore_mapped_memory_size, prop.getProperty("relationshipstore_mapped_memory_size")). setConfig(GraphDatabaseSettings.strings_mapped_memory_size, prop.getProperty("strings_mapped_memory_size")). setConfig(GraphDatabaseSettings.use_memory_mapped_buffers, prop.getProperty("use_memory_mapped_buffers")). setConfig(GraphDatabaseSettings.relationship_auto_indexing, prop.getProperty("relationship_auto_indexing")). newGraphDatabase(); // Server Configuration ServerConfigurator config; config = new ServerConfigurator(graphdb); config.configuration().setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, DB_EMBED_PORT); config.configuration().setProperty(Configurator.DB_TUNING_PROPERTY_FILE_KEY, DB_TUNE_FILE); config.configuration().setProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, SERVER_HOSTNAME); try { srv = new WrappingNeoServerBootstrapper(graphdb, config); srv.start(); } catch (Exception e) { log.warn("DS Error : " + e.getLocalizedMessage()); e.printStackTrace(); } graphDb = graphdb; registerShutdownHook(graphDb); // To Create the Query Excecution Engine try { log.info("Query Execution Engine Creation Started"); executionEngine = new ExecutionEngine(graphDb, StringLogger.SYSTEM); log.info("Query Execution Engine Creation Finished"); } catch (Exception e) { log.error("Exception on Query Execution Engine Creation, " + e.getLocalizedMessage()); e.printStackTrace(); } return graphDb; } private static void registerShutdownHook(final GraphDatabaseService graphDb) { Runtime.getRuntime().addShutdownHook(new Thread() { @Override public void run() { graphDb.shutdown(); srv.stop(); } }); } } ====================================================================== On Sunday, 22 March 2015 08:41:24 UTC, Michael Hunger wrote: > > You create two instances of GraphDatabaseService? > > Also as you create connections to the root node you might get contention > on that root node too. > > Please do create only ONE instance of ExecutionEngine and keep it with the > GraphDatabaseService. > > I'd probably switch to an index based approach than a reference node based > approach and use the NodeUniqueFactory with an index instead which is less > lock sensitive. > > I can only recommed to you to trace your open transactions (e.g. via JMX > and find the one that's still open e.g. for the root node). > Those might be other transactions which are missing a tx.success() that > lock the root node. > > Michael > > Am 22.03.2015 um 00:20 schrieb S C Kannan <[email protected] > <javascript:>>: > > Hello Michael, > > Thanks for quick response. I have added the two class files below. > (NeoUtil & DataSource) which are used in the code provided. > > Minimum Heap Size 128MB > Maximum Heap Size 1024MB > > Yes we have hidden transaction there which was stated on NeoUtil class > findParentNode method. If Parent Node Not available, the method will create > the parent Node. We have stated the respective methods code in the Neo Util > class. > > > *NeoUtil Class* > ============================== > ===================================================================== > public class NeoUtil { > public static Node findParentNode(String nodeName) { > String strCipherQuery = "START root=node(1) MATCH root" > + "-[:TABLE]->tb " > + " WHERE tb.name='" + nodeName + "' " > + " RETURN tb"; > try { > > Node node = executeCypherQuerySingleResult(strCipherQuery, > "tb"); > if (null != node) { > return node; > } else { > createReferenceNode(nodeName); > } > > } catch (Exception e) { > e.printStackTrace(); > log.warn("Exception while find Node using Name : " + nodeName > + ".. Error is : " + e.getLocalizedMessage()); > } > return null; > } > > public static Node executeCypherQuerySingleResult(String > strCypherQuery, String strResultColumnName) { > ExecutionResult result = null; > ExecutionEngine engine = null; > try { > engine = new ExecutionEngine(DataSource.getGraphDBAPI(), > StringLogger.SYSTEM); > result = engine.execute(strCypherQuery); > } catch (Exception e) { > log.warn("Exception on Executing Cypher Query : " + > strCypherQuery + ".. Error is : " + e.getLocalizedMessage()); > } finally { > engine = null; > } > return nodeFromResult(result, strResultColumnName); > } > > public static Node nodeFromResult(ExecutionResult result, String > column) { > Iterator<Node> n_column; > try { > n_column = result.columnAs(column); > Node node = null; > while (n_column.hasNext()) { > node = n_column.next(); > return node; > } > return null; > } catch (Exception e) { > return null; > } finally { > n_column = null; > } > } > > public static Node createReferenceNode(String refNode) { > log.info("refNode : " + refNode); > Transaction tx = DataSource.getGraphDBAPI().beginTx(); > > try { > //Get the root Node > Node rootNode = executeCypherQuerySingleResult("start > rt=node(1) return rt", "rt"); > > //Create the new node > Node neoNode = DataSource.getGraphDB().createNode(); > //Set the name for that node > neoNode.setProperty("name", refNode); > > //relate the new node to the parent node > rootNode.createRelationshipTo(neoNode, TABLE); > tx.success(); > } catch (Exception e) { > tx.failure(); > log.warn("Exception on Creating Reference Node." + ".. Error > is : " + e.getLocalizedMessage()); > } finally { > tx.finish(); > } > } > } > > =============================================================================================== > *DataSource Class* > > =============================================================================================== > public class DataSource { > > static GraphDatabaseService graphDb = null; > > public static GraphDatabaseService getGraphDBAPI() { > > return graphDb; > } > > public static GraphDatabaseService dbStart() { > String glassfishInstanceRootPropertyName = > "com.sun.aas.instanceRoot"; > String serverLocation = > System.getProperty(glassfishInstanceRootPropertyName) ; > String fileName = serverLocation + "/config/neoDb.conf"; > > log.info("Database Config File Path : " + fileName); > Properties prop = new Properties(); > try { > // the configuration file name > InputStream is = new FileInputStream(fileName); > > // load the properties file > prop.load(is); > } catch (IOException e) { > log.warn("Exception With Db Setup : " + > e.getLocalizedMessage()); > } > DB_PATH = prop.getProperty("graphdb.location"); > DB_EMBED_PORT = prop.getProperty("graphdb.port"); > SERVER_HOSTNAME = prop.getProperty("graphdb.server.hostname"); > UPLOAD_FILE_LOC = serverLocation + prop.getProperty("upload.dir"); > > DB_TUNE_FILE = serverLocation+"/config/neo4j.properties"; > > log.info("Properties File : " + DB_PATH); > > // Create Database with Properties > GraphDatabaseAPI graphdb = (GraphDatabaseAPI) new > GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_PATH). > setConfig(GraphDatabaseSettings.node_keys_indexable, > prop.getProperty("node_keys_indexable")). > setConfig(GraphDatabaseSettings.node_auto_indexing, > prop.getProperty("node_auto_indexing")). > setConfig(GraphDatabaseSettings.cache_type, > prop.getProperty("cache_type")). > setConfig(GraphDatabaseSettings.allow_store_upgrade, > prop.getProperty("allow_store_upgrade")). > > setConfig(GraphDatabaseSettings.nodestore_propertystore_mapped_memory_size, > prop.getProperty("nodestore_propertystore_mapped_memory_size")). > > setConfig(GraphDatabaseSettings.nodestore_mapped_memory_size, > prop.getProperty("nodestore_mapped_memory_size")). > > setConfig(GraphDatabaseSettings.relationshipstore_mapped_memory_size, > prop.getProperty("relationshipstore_mapped_memory_size")). > > setConfig(GraphDatabaseSettings.strings_mapped_memory_size, > prop.getProperty("strings_mapped_memory_size")). > setConfig(GraphDatabaseSettings.use_memory_mapped_buffers, > prop.getProperty("use_memory_mapped_buffers")). > > setConfig(GraphDatabaseSettings.relationship_auto_indexing, > prop.getProperty("relationship_auto_indexing")). > newGraphDatabase(); > > > GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_PATH).setConfig(ShellSettings.remote_shell_enabled, > > GraphDatabaseSetting.TRUE).newGraphDatabase(); > > // Server Configuration > ServerConfigurator config; > config = new ServerConfigurator(graphdb); > > config.configuration().setProperty(Configurator.WEBSERVER_PORT_PROPERTY_KEY, > DB_EMBED_PORT); > > config.configuration().setProperty(Configurator.DB_TUNING_PROPERTY_FILE_KEY, > DB_TUNE_FILE); > > config.configuration().setProperty(Configurator.WEBSERVER_ADDRESS_PROPERTY_KEY, > > SERVER_HOSTNAME); > > try { > srv = new WrappingNeoServerBootstrapper(graphdb, config); > srv.start(); > } catch (Exception e) { > log.warn("DS Error : " + e.getLocalizedMessage()); > e.printStackTrace(); > } > > graphDb = graphdb; > registerShutdownHook(graphDb); > return graphDb; > } > > private static void registerShutdownHook(final GraphDatabaseService > graphDb) { > Runtime.getRuntime().addShutdownHook(new Thread() { > > @Override > public void run() { > graphDb.shutdown(); > srv.stop(); > } > }); > } > } > > > ====================================================================================================== > > The Node find Query(Point 7) was done on console. Not from Source. > > Best Regards, > Kannan S C > > > On Saturday, 21 March 2015 20:20:59 UTC, Michael Hunger wrote: >> >> In principle your code looks ok, >> >> It's not clear which code/database your neoUtil.findParentNode("Test"); >> uses >> and what DataSource.getGraphDBAPI() does >> >> how much heap do you provide to your application? >> >> >> Am 21.03.2015 um 20:04 schrieb S C Kannan <[email protected]>: >> >> Hi Michael, >> >> Thanks for the response. I have added the exact fail case scenario with >> codes and configuration as follows, >> >> We are using single threaded only. >> >> I am using Neo4j 1.9.8 Embedded Database. The steps used to create node >> are as follows, >> >> 1. Start the Transaction >> 2. Create the Node. >> 3. Set few properties to the node >> 4. Create two relationships with other nodes >> >> I see only one relationship-creation in your code >> >> 5. Commit the transaction >> 6. Print the Node Id (eg. 13456) >> >> where is that? >> >> 7. Fetch the particular Node with the Node Id above with following query. >> START root=node(13456) RETURN root;But the following error throws >> >> I think somehow you either leak transactions so you still have a write >> lock at the node(s) (probably the parent-node) which is not unlocked yet >> and your second tx hangs on the same lock. >> Do you have outer transactions that you don't show here? >> >> >> EntityNotFoundException: Node 13456 not found >> >> When I try to do the above transaction again, the program hangs at point >> no 4. >> >> The Java Class used to create node with property and relation ship are as >> follows, >> >> Transaction trx = DataSource.getGraphDBAPI().beginTx(); >> try{ >> Node ndeTest= DataSource.getGraphDB().createNode(); >> ndeTest.setId("1"); >> ndeTest.setName("Test API"); >> ndeTest.setURL("www.test.com"); >> Node parentNode = neoUtil.findParentNode("Test"); >> parentNode.createRelationshipTo(ndeTest, >> KnoxxiRelationshipType.API); >> ndeTest.setStatus("1"); >> trx.success(); >> }catch (Exception e) { >> trx.failure(); >> log.error("Test Node Creation Failed," + e.getLocalizedMessage); >> } finally {trx.finish();} >> log.info("Node Id : "+ ndeTest.getId()); >> >> The neo4j Configuration are as follows: >> >> 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 >> relationship_auto_indexing=true >> >> The last few lines on neo4j message.log file are as follows: >> >> >> 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] >> >> Please guide me if i miss something out. >> >> Best Regards, >> Kannan S C >> >> On Friday, 20 March 2015 10:27:14 UTC, Michael Hunger wrote: >>> >>> Please share you code, best a failing test, neo4j version, data model. >>> Are you running single threaded or multi threaded, ... >>> >>> M >>> >>> Am 20.03.2015 um 11:12 schrieb S C Kannan <[email protected]>: >>> >>> Hi Experts, >>> >>> I am facing an issue which was stated as follows, >>> >>> 1. I can able to use cipher query to fetch records. But when i save a >>> new node and Create relationship to the someother node, Neo4j hangs and >>> nothing happens after that. There are no error logs on Message.log. >>> >>> Please help to sort this out' >>> >>> With Regards, >>> Kannan S C >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Neo4j" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> For more options, visit https://groups.google.com/d/optout. >>> >>> >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Neo4j" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> For more options, visit https://groups.google.com/d/optout. >> >> >> > -- > You received this message because you are subscribed to the Google Groups > "Neo4j" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected] <javascript:>. > For more options, visit https://groups.google.com/d/optout. > > > -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
