title: Titan Cassandra Multithreaded Transactions Locking
body: <p>I have created a class which wraps within it a <code>Graph</code>. For example:</p>
  
  <pre><code>public class GraphManager(){
      Graph graph;
      public GraphManager(Graph graph){
          this.graph = graph;
      }
      public void commitGraph(){
          graph.commit();
      }
  }
  </code></pre>
  
  <p>This <code>GraphManager</code> allows me to interact with the graph in predefined ways. I construct this <code>GraphManager</code> using a factory:</p>
  
  <pre><code>public class GraphManagerFactory(){
      public static GraphManager getGraphManager(){
          return new GraphManager(TitanFactory.open("conf/titan-cassandra.properties"));
      }
  }
  </code></pre>
  
  <p>That is the base framework. Now onto the problem, using a rest controller I receive a JSON file. This results in instantiating a <code>GraphManager</code> which translates the file into a graph and then commits it. The basic paradigm is as follows:</p>
  
  <pre><code>public class Controller(){
      public List&lt;String&gt; handleRequest(){
          GraphManager manager = GraphManagerFactory.getGraphManager();
          //Do some work with graph manager
          synchronised(Controller.class){
              manager.commitGraph();
          }
      }
  }
  </code></pre>
  
  <p>With the code above I assure that only one thread can commit to the graph at any time. However despite that I still get a <code>PermanentLockingException</code>:</p>
  
  <pre><code>com.thinkaurelius.titan.diskstorage.locking.PermanentLockingException: Local lock contention
  at com.thinkaurelius.titan.diskstorage.locking.AbstractLocker.writeLock(AbstractLocker.java:313) ~[titan-core-1.0.0.jar:na]
  at com.thinkaurelius.titan.diskstorage.locking.consistentkey.ExpectedValueCheckingStore.acquireLock(ExpectedValueCheckingStore.java:89) ~[titan-core-1.0.0.jar:na]
  at com.thinkaurelius.titan.diskstorage.keycolumnvalue.KCVSProxy.acquireLock(KCVSProxy.java:40) ~[titan-core-1.0.0.jar:na]
  at com.thinkaurelius.titan.diskstorage.BackendTransaction.acquireIndexLock(BackendTransaction.java:240) ~[titan-core-1.0.0.jar:na]
  at com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.prepareCommit(StandardTitanGraph.java:554) ~[titan-core-1.0.0.jar:na]
  at com.thinkaurelius.titan.graphdb.database.StandardTitanGraph.commit(StandardTitanGraph.java:683) ~[titan-core-1.0.0.jar:na]
  at com.thinkaurelius.titan.graphdb.transaction.StandardTitanTx.commit(StandardTitanTx.java:1352) [titan-core-1.0.0.jar:na]
  at com.thinkaurelius.titan.graphdb.tinkerpop.TitanBlueprintsGraph$GraphTransaction.doCommit(TitanBlueprintsGraph.java:263) [titan-core-1.0.0.jar:na]
  at org.apache.tinkerpop.gremlin.structure.util.AbstractTransaction.commit(AbstractTransaction.java:94) [gremlin-core-3.0.2-incubating.jar:3.0.2-incubating]
  at io.mindmaps.core.accessmanager.GraphAccessManagerImpl.commit(GraphAccessManagerImpl.java:811) [mindmaps-core-0.0.5-SNAPSHOT.jar:na]
  at io.mindmaps.graphmanager.listener.TransactionController.commitGraph(TransactionController.java:98) [classes/:na]
  at io.mindmaps.graphmanager.listener.TransactionController.validateAndCommit(TransactionController.java:84) [classes/:na]
  at io.mindmaps.graphmanager.listener.TransactionController.loadData(TransactionController.java:66) [classes/:na]
  at io.mindmaps.graphmanager.listener.TransactionController.lambda$postTransaction$0(TransactionController.java:43) [classes/:na]
  at io.mindmaps.graphmanager.loader.QueueManager.handleJob(QueueManager.java:76) ~[classes/:na]
  at io.mindmaps.graphmanager.loader.QueueManager.lambda$addJob$3(QueueManager.java:24) ~[classes/:na]
  at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_66]
  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_66]
  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_66]
  at java.lang.Thread.run(Thread.java:745) ~[na:1.8.0_66]
  </code></pre>
  
  <p>How can this occur when only one commit is allowed at a time ?</p>