title: Neo4j - Unable to rollback transaction in creating relationships with java
body: <p>I am trying to create some nodes in Neo4j through a Maven Java Application and create relationships between those nodes. Exactly i want to create 16807 nodes and 17210368 relationships. I read a file and get the <code>row</code> variable which has the number of nodes i must create and i also have a <code>list</code> which has 34420736 elements (=17210368*2). I want to create a relationship from node[element 0 of list] to node[element 1 from list], from node[element 2 of list] to node[element 3 from list] etc. Also the max element of list is 16807. I create an <code>ArrayList&lt;Node&gt;</code> as to create the nodes dynamically cause i want the programm to run with different files(and with different row values).</p>
  
  <p>Here is my code:</p>
  
  <pre><code>    GraphDatabaseFactory dbFactory = new GraphDatabaseFactory();
      GraphDatabaseService graphDb = dbFactory.newEmbeddedDatabase("C:\Users\....\default.graphdb");
  
      Transaction tx = graphDb.beginTx();
      try {
          final RelationshipType type2 = DynamicRelationshipType.withName("KNOW");
  
          ArrayList&lt;Node&gt; nodelist = new ArrayList&lt;Node&gt;();
  
          for (int k = 0; k &lt; row; k++) { //row=16807
              nodelist.add(graphDb.createNode());
              nodelist.get(k).setProperty("Name", "ListNode  " + k);
          }       
  
          int count=0;
          for (int j = 0; j &lt; list.size() ; j++) { //list.size()=34420736
              nodelist.get(list.get(count)).createRelationshipTo(nodelist.get(list.get(count+1)), type2);
              count=count+2;
          }
  
          tx.success();
      }
      finally {
          tx.close();
      }
      graphDb.shutdown();
  </code></pre>
  
  <p>If i run the code without trying to create relationships it creates the nodes and run correctly. When i add the for loop that creates the realtionships it throws me the following error:</p>
  
  <pre><code>Exception in thread "main" org.neo4j.graphdb.TransactionFailureException: Unable to rollback transaction
  at org.neo4j.kernel.TopLevelTransaction.close(TopLevelTransaction.java:131)
  at com.mycompany.traverse_test.traverse_main.main(traverse_main.java:138)
  Caused by: java.lang.IllegalStateException: No RelationshipState for added relationship!
  at org.neo4j.kernel.api.txstate.RelationshipChangeVisitorAdapter$1.visit(RelationshipChangeVisitorAdapter.java:132)
  at org.neo4j.kernel.api.txstate.RelationshipChangeVisitorAdapter.visitAddedRelationship(RelationshipChangeVisitorAdapter.java:83)
  at org.neo4j.kernel.api.txstate.RelationshipChangeVisitorAdapter.visitAdded(RelationshipChangeVisitorAdapter.java:106)
  at org.neo4j.kernel.api.txstate.RelationshipChangeVisitorAdapter.visitAdded(RelationshipChangeVisitorAdapter.java:47)
  at org.neo4j.kernel.impl.util.diffsets.DiffSets.accept(DiffSets.java:76)
  at org.neo4j.kernel.impl.api.state.TxState.accept(TxState.java:156)
  at org.neo4j.kernel.impl.api.KernelTransactionImplementation.rollback(KernelTransactionImplementation.java:542)
  at org.neo4j.kernel.impl.api.KernelTransactionImplementation.close(KernelTransactionImplementation.java:404)
  at org.neo4j.kernel.TopLevelTransaction.close(TopLevelTransaction.java:112)
  ... 1 more
  </code></pre>
  
  <p>Any ideas??</p>