Support Cypher transactions

Issue #91 wontfix
Tatham Oddie
created an issue

Comments (11)

  1. Tatham Oddie reporter

    Some thoughts:

    • We should throw a NotSupportedException if they try to start a transaction where graphClient.Version < 2.0.
    • We should throw a NotSupportedException if they try to invoke non-Cypher graph calls within a transaction
  2. Jamal Mavadat

    In terms of API design how about the following basic API:

    ITransaction IGraphClient.BeginTransaction();
    void ITransaction.Commit();
    void ITransaction.Rollback();
    void KeepAlive(); //optional - to prevent transaction becoming orphan but comes with great responsibility
    void ITransaction:IDisposable.Dispose(); //mainly for the "using" keyword
    1. Default isolation level is used: READ_COMMITTED which supports repeatable read within same transaction
    2. Default transaction timeout value is used (org.neo4j.server.transaction.timeout : 60 seconds)
    3. Read/write locks are only applicable to node and relationship CRUD operations. So we'll introduce the following API changes as well:
    NodeReference<TNode> IGraphClient.Create<TNode>(
       TNode node,
       IEnumerable<IRelationshipAllowingParticipantNode<TNode>> relationships,
       ITransaction transaction = null);
    Node<TNode> IGraphClient.Get<TNode>(NodeReference reference, ITransaction transaction = null);
    Task<Node<TNode>> IGraphClient.GetAsync<TNode>(NodeReference reference, ITransaction transaction = null);
    void IGraphClient.Update<TNode>(
       NodeReference<TNode> nodeReference,
       TNode replacementData,
       ITransaction transaction = null); //no option to update indexes
    void IGraphClient.Delete(NodeReference reference, DeleteMode mode, ITransaction transaction);
    RelationshipReference IGraphClient.CreateRelationship<TSourceNode, TRelationship>(
       NodeReference<TSourceNode> sourceNodeReference,
       TRelationship relationship,
       ITransaction transaction = null);
    void IGraphClient.DeleteRelationship(RelationshipReference reference, ITransaction transaction = null);
    void ICypherFluentQuery.Delete(string identities, ITransaction transaction = null);
    void ICypherFluentQuery Relate(string relateText, ITransaction transaction = null);


    • No gremlin support
    • INDEX operations cannot be done within transaction
    • There would be some breaking changes like after deleting a node/relationship within transaction we can still read them until transaction commits. This behaviour has potential in breaking existing code.

    Thoughts? How can we improve this?

  3. Log in to comment