Hi Xander,
You should consider TransactionalGraph graph instance as connection and
this connection should be thread local.
But you have shared connection.

On Mon, Oct 27, 2014 at 5:53 PM, Xander Uiterlinden <
[email protected]> wrote:

> Hi,
>
> I've been working on upgrading our graph code from OrientDB 1.7 to
> OrientDB 2.0M2. Since we're using the blueprints API's this was quite easy,
> however I noticed a difference regarding transactions with the new OrientDB
> version.
>
> Using the TransactionalGraph API a transaction is supposed to be bound to
> a thread, so commit() and rollback() invocations on different threads
> should not have effect on each other. This appears not to be the case with
> the new version.
>
> See the following code:
>
> final TransactionalGraph graph = m_graph.getGraph();
>
> Runnable r1 = new Runnable() {
>
>     @Override
>     public void run() {
>         Vertex vertex = graph.addVertex(null);
>         System.out.println("add v1");
>         vertex.setProperty("name", "v1");
>         vertex.setProperty("category", "v");
> // delay the commit to check whether the rollback on the other thread has
> any effect on what we're doing here
>         try {
> Thread.sleep(1000);
> } catch (InterruptedException e) {
> }
>         System.out.println("graph commit");
>         graph.commit();
>     }
>
> };
>
> // Thread 2 appears to roll-back the work that was done but not yet
> committed in thread 1.
> Runnable r2 = new Runnable() {
>
>     @Override
>     public void run() {
>         try {
> Thread.sleep(500);
> } catch (InterruptedException e) {
> }
>         System.out.println("graph rollback");
>     graph.rollback();
>     }
> };
>
> new Thread(r1).start();
> new Thread(r2).start();
>
> try {
>     Thread.sleep(1500);
> }
> catch (InterruptedException e) {
> }
> System.out.println("wake and check");
> Iterable<Vertex> vertices = graph.getVertices("category", "v");
> long count = StreamSupport.stream(vertices.spliterator(), false).count();
> assertEquals(1, count);
>
> To me this seems like a bug, or am I overlooking something ?
>
> Thanks,
>
> Xander
>
> --
>
> ---
> You received this message because you are subscribed to the Google Groups
> "OrientDB" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Best regards,
Andrey Lomakin.

Orient Technologies
the Company behind OrientDB

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to