RC5 transaction problems

21 views
Skip to first unread message

Ivanhoe Abrahams

unread,
Aug 25, 2011, 11:06:08 AM8/25/11
to orient-...@googlegroups.com
Hi all

I have a simple example which fails when I use transaction boundaries on RC5

First I add 10 Vertices (ALL OF THESE ARE CREATED WITHIN A SINGLE TRANSACTION)
Then I add 5 edges between them
     so the edges are
          1 -> 2
          2 -> 4
          3 -> 6
          4 -> 8
          5 -> 10
NOTE: Each Edge is created WITHIN a transaction.

However on the second create of an edge I get the following exception

Exception in thread "main" com.orientechnologies.orient.core.exception.OStorageException: Error on commit
    at com.orientechnologies.orient.client.remote.OStorageRemote.handleException(OStorageRemote.java:1011)
    at com.orientechnologies.orient.client.remote.OStorageRemote.commit(OStorageRemote.java:799)
    at com.orientechnologies.orient.client.remote.OStorageRemoteThread.commit(OStorageRemoteThread.java:198)
    at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.executeCommit(ODatabaseRecordTx.java:240)
    at com.orientechnologies.orient.core.tx.OTransactionOptimistic.commit(OTransactionOptimistic.java:43)
    at com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.commit(ODatabaseRecordTx.java:113)
    at com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.commit(ODatabaseDocumentTx.java:243)
    at com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph.stopTransaction(OrientGraph.java:354)
    at com.ldodds.slug.http.storage.ReadSailGraph.addEdges(ReadSailGraph.java:93)
    at com.ldodds.slug.http.storage.ReadSailGraph.main(ReadSailGraph.java:38)
Caused by: java.lang.ArrayIndexOutOfBoundsException: -1
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.createException(OChannelBinary.java:376)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinary.handleStatus(OChannelBinary.java:330)
    at com.orientechnologies.orient.enterprise.channel.binary.OChannelBinaryAsynch.beginResponse(OChannelBinaryAsynch.java:83)
    at com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(OStorageRemote.java:1333)
    at com.orientechnologies.orient.client.remote.OStorageRemote.commit(OStorageRemote.java:755)
    ... 8 more


Regards
Ivanhoe

Luca Garulli

unread,
Sep 6, 2011, 4:45:18 AM9/6/11
to orient-...@googlegroups.com
Hi Ivanhoe,
could you provide a test case to reproduce the problem?

Lvc@

Ivanhoe Abrahams

unread,
Sep 7, 2011, 7:43:25 AM9/7/11
to orient-...@googlegroups.com
Hi Luca

Herewith the example



import java.util.List;

import com.orientechnologies.orient.core.db.graph.OGraphVertex;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.metadata.schema.OProperty.INDEX_TYPE;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.query.OSQLSynchQuery;
import com.tinkerpop.blueprints.pgm.Vertex;
import com.tinkerpop.blueprints.pgm.TransactionalGraph.Conclusion;
import com.tinkerpop.blueprints.pgm.TransactionalGraph.Mode;
import com.tinkerpop.blueprints.pgm.impls.orientdb.OrientGraph;

public class OrientDBTests {


    /**
     * @param args
     */
    public static void main(String[] args) {
        OrientGraph graph = new OrientGraph("remote:localhost/scratchpad", "admin", "admin");
        graph.setTransactionMode(Mode.MANUAL);
        graph.getRawGraph().getMetadata().getSchema().getClass(OGraphVertex.class).createProperty("name", OType.STRING).createIndex(INDEX_TYPE.UNIQUE);
        graph.getRawGraph().getMetadata().getSchema().save();


        addVertices(graph);
        addEdges(graph);
       
        List<ODocument> results = graph.getRawGraph().query(new OSQLSynchQuery<Vertex>("select from V where out contains (label = 'knows')"));
        for (ODocument document : results) {
            String[] fieldNames = document.fieldNames();
            for (int i = 0; i < fieldNames.length; i++) {
                String fieldName = (String) fieldNames[i];
                System.out.println(fieldName);
            }
        }
        graph.shutdown();
    }

   
   
   
    private static void addVertices(OrientGraph graph) {
        graph.startTransaction();
        for (int i = 0; i < 1000; i++) {
            Vertex luca = graph.addVertex(null);
            luca.setProperty("name", "Name-" + i);
            System.out.println("Added Vertex : " + luca.getProperty("name") + " Id : " + luca.getId());
        }
        graph.stopTransaction(Conclusion.SUCCESS);
        System.out.println("Committing Vertices !!!");

    }
   
   
    private static void addEdges(OrientGraph graph) {
        OSQLSynchQuery<ODocument> query =  new OSQLSynchQuery<ODocument>("SELECT FROM OGraphVertex WHERE name = ? or name = ?");
        for (int j = 1; j < 500; j++) {
            long q1 = 0;
            long q2 = 0;
            long g1 = 0;
            long g2 = 0;
            long add = 0;
            long start = System.currentTimeMillis();
            List<ODocument> results = graph.getRawGraph().query(query, "Name-" + j, "Name-" + (j*2));
            long end = System.currentTimeMillis();
            q1 = (end - start);
            if (results != null ){
                graph.startTransaction();
                Vertex v1 = graph.getVertex(results.get(0).getIdentity());
                Vertex v2 = graph.getVertex(results.get(1).getIdentity());
                graph.addEdge(null, v1, v2, "knows");
                graph.stopTransaction(Conclusion.SUCCESS);

            }
            System.out.println("Added Edge Stats for Edge " + j + "->" + (j*2));
        }
       
    }
}




PS. Let me know if somethig is obviously wrong

Regards
Ivanhoe

Luca Garulli

unread,
Sep 8, 2011, 6:11:29 AM9/8/11
to orient-...@googlegroups.com
Hi Ivanhoe,
your test runs without problems on my PC against a brand new "scratchpad" db.

This is the output:

Added Vertex : Name-0 Id : #-1:-2
Added Vertex : Name-1 Id : #-1:-3
....
Added Vertex : Name-998 Id : #-1:-1000
Added Vertex : Name-999 Id : #-1:-1001
Committing Vertices !!!
Added Edge Stats for Edge 1->2
Added Edge Stats for Edge 2->4
...
Added Edge Stats for Edge 498->996
Added Edge Stats for Edge 499->998
name
out
name
...
in
out
name
out


Lvc@

Ivanhoe Abrahams

unread,
Sep 8, 2011, 6:20:37 AM9/8/11
to orient-...@googlegroups.com
Hi Luca

Should I be using the latest snapshot?
Can you possibly supply me the versions of the server and also the maven artifacts that tyou are using?
That would be highly appreciated

Regards
Ivanhoe

Luca Garulli

unread,
Sep 8, 2011, 6:24:52 AM9/8/11
to orient-...@googlegroups.com
Hi,
I always use latest SVN trunk. Maven snapshots are updated at 2-3 days ago, so everything is supposed to work.

Lvc@
Reply all
Reply to author
Forward
0 new messages