Causal Cluster. Data not in Graph even after Transaction Termination

82 Views Asked by At

We are using Neo4j Enterprise edition for Causal Clustering. There are 3 core nodes and 3 replica nodes.

Is it necessary that Session be closed explicitly for data to be visible in the neo4j database. I am creating close to 20K transactions (each of them creating one node) in each session with each transaction being explicitly calling success();

I have observed that unless the session is terminated, data is not visible in the Neo4J graph (browser) and also from Neo4j shell.

Am I doing something wrong? I wish that since each transaction is followed by success() method explicitly, I should be able to see the data as soon as success() is returned from the transaction.

Does Neo4J (bolt Driver) wait for the completion of the session before committing all transaction data in Graph? All these transactions are stand alone transactions having no relation to the previous or upcoming transaction?

Kindly enlighten.

2

There are 2 best solutions below

0
On

It looks as if the transaction does not close automatically in the block try catch.

You can manually close a transaction without closing the session: [ https://neo4j.com/docs/java-reference/current/javadocs/org/neo4j/graphdb/Transaction.html#close-- ]:

 Transaction tx = graphDb.beginTx();
 try
 {
     // operations on the graph
     // ...

     tx.success();
 }
 finally
 {
     tx.close();
 }
0
On

Transaction.close() does the actual commit or rollback operation, depending on whether success() or failure() had been called earlier on the same transaction (failure is the default if neither were called).

If a transaction is still active when you call Session.close(), it will close the transaction for you (there can be at most one active at a time per session). But you do not have to close the session to perform an actual commit or rollback -- you can just directly close the current transaction yourself. After that, you can use the same session to create a new transaction, if you want. (In addition, you can have multiple sessions at the same time.)