7.1. Transaction Handling

This section describes the usage of transactions during the execution of an algorithm. When an algorithm procedure is called from Cypher, the procedure call is executed within the same transaction as the Cypher statement.

This section includes:

7.1.1. During graph projection

During graph projection, new transactions are used that do not inherit the transaction state of the Cypher transaction. This means that changes from the Cypher transaction state are not visible to the graph projection transactions.

For example, the following statement will only create an empty graph (assuming the MyLabel label was not already present in the Neo4j database):

CREATE (n:MyLabel) // the new node is part of Cypher transaction state
WITH *
CALL gds.graph.create('myGraph', 'MyLabel', '*')
YIELD nodeCount
RETURN nodeCount

Table 7.1. Results
nodeCount

0

The situation is the same when using an anonymous projection with an algorithm procedure:

CREATE (n:MyWccLabel) // the new node is part of Cypher transaction state
WITH *
CALL gds.wcc.stats({nodeProjection: 'MyWccLabel', relationshipProjection:'*'})
YIELD componentCount
RETURN componentCount

Table 7.2. Results
componentCount

0

7.1.2. During results writing

Results from algorithms (node properties, for example) are written to the graph in new transactions. The number of transactions used depends on the size of the results and the writeConcurrency configuration parameter (for more details, please refer to sections Section 3.3.4, “Write” and Section 6.1.1, “Configuration parameters”). These transactions are committed independently from the Cypher transaction. This means, if the Cypher transaction is terminated (either by the user or by the database system), already committed write transactions will not be rolled back.

7.1.3. Transaction termination

The Cypher transaction can be terminated by either the user or the database system. This will eventually terminate all transactions that have been opened during graph projection, algorithm execution, or results writing. It is not immediately visible and can take a moment for the transactions to recognize that the Cypher transaction has been terminated.