question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot update the record because the version is not the latest

See original GitHub issue

Hi,

This is probably a very old question, but slightly different in my case and haven’t found answer in group, so post it again.

Following is my code snippet.

  1. With blueprints
    @Test
    public void testTransaction() {
        OrientGraph graph = new OrientGraph("remote:localhost/tmp", "admin", "admin");

        Vertex a = null;
        try {
            a = graph.addVertex(null);
            graph.stopTransaction(TransactionalGraph.Conclusion.SUCCESS);
        } catch (Exception e) {
            graph.stopTransaction(TransactionalGraph.Conclusion.FAILURE);
            e.printStackTrace();
        }

        try {
            for (int i = 0; i < 100; ++i) {
                graph.addEdge(null, graph.addVertex(null), a, "");
            }
            graph.stopTransaction(TransactionalGraph.Conclusion.SUCCESS);
        } catch (Exception e) {
            graph.stopTransaction(TransactionalGraph.Conclusion.FAILURE);
            e.printStackTrace();
        }

        try {
            Vertex b = graph.addVertex(null);
            graph.addEdge(null, b, a, "");
            graph.stopTransaction(TransactionalGraph.Conclusion.SUCCESS);
        } catch (Exception e) {
            graph.stopTransaction(TransactionalGraph.Conclusion.FAILURE);
            e.printStackTrace();
        } finally {
            graph.shutdown();
        }
    }
  1. Without blueprints
    @Test
    public void testTransactionNative() {
        OGraphDatabase db = new OGraphDatabase("remote:localhost/tmp");
        db.open("admin", "admin");

        ODocument a = null;
        try {
            db.begin(OTransaction.TXTYPE.OPTIMISTIC);

            a = db.createVertex().save();

            db.commit();
        } catch (Exception e) {
            db.rollback();
            e.printStackTrace();
        }

        try {
            db.begin(OTransaction.TXTYPE.OPTIMISTIC);

            for (int i = 0; i < 100; ++i) {
                db.createEdge(db.createVertex().save(), a.save()).save();
            }

            db.commit();
        } catch (Exception e) {
            db.rollback();
            e.printStackTrace();
        }

        try {
            db.begin(OTransaction.TXTYPE.OPTIMISTIC);

            db.createEdge(db.createVertex().save(), a.save()).save();

            db.commit();
        } catch (Exception e) {
            db.rollback();
            e.printStackTrace();
        } finally {
            db.close();
        }
    }

Both versions I will get exception when committing the third transaction like: om.orientechnologies.orient.core.exception.OConcurrentModificationException: Cannot UPDATE the record #7:4 because the version is not the latest. Probably you are updating an old record or it has been modified by another user (db=v2 your=v1)

The problem here is “a” actually, when I create the edge, if I try to “save” it again, then I will get the above exception; while if not, everything is fine.

But in blueprints, “a” will always be saved:

public Edge addEdge(final Object id, final Vertex outVertex, final Vertex inVertex, final String label) {
        // ...

        // SAVE THE VERTICES TO ASSURE THEY ARE IN TX
        db.save(((OrientVertex) outVertex).getRawElement());
        db.save(((OrientVertex) inVertex).getRawElement());
        edge.save();
        return edge;
    }

I’ve tried to disable level1 and level2 cache, and disable mvcc, but nothing works.

How can I solve this problem? Or is it not expected to use a vertex/edge created in another transaction?

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:47 (24 by maintainers)

github_iconTop GitHub Comments

1reaction
Tushavicommented, Jul 13, 2018

Hi @maggiolo00 , I upgraded the version to 3.04, it works way better now. There are very infrequent instances, when i get the same error, but the gremlin requests are not freezing now.

1reaction
Tushavicommented, Jul 10, 2018

I am having a similar error. I am using orientDB-tp3-3.0.2 and gremlin_python to connect to orientdb and run queries. I open a thread from the python application (only 1 thread), it runs all gremlin queries sequentially.

Right now I am testing with 3 vertices and 2 edges creation. I successfully create the 3 vertices and am able to create the first edge. The second edge creation throws the error : 500: Cannot UPDATE the record #23:8 because the version is not the latest. Probably you are updating an old record or it has been modified by another user (db=v2 your=v1)

I also get a similar error when I try to drop the graph. I use : > g.E().drop().iterate() - works fine > g.V().drop().iterate() - throws error > g.V().drop().iterate() - works fine after a few tries and after trying some other queries in between

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot update the record because the version is not the latest
Hi, I am having the following issue while using update Vertex in multiple threads in java API with blueprints using OrientGraph connection ...
Read more >
ERROR OConcurrentModificationException Cannot UPDATE ...
ERROR OConcurrentModificationException Cannot UPDATE the record because the version is not the latest during upgrade of npm repositories.
Read more >
Record version after conflict - orientdb - Stack Overflow
OConcurrentModificationException : Cannot UPDATE the record #18:0 because the version is not the latest. Probably you are updating an old ...
Read more >
ORA-20010 Error When Updating Records - My Oracle Support
The ID column is generated using a sequence and trigger. The records can be updated fine using another tool such as TOAD or...
Read more >
Java · OrientDB Manual
OConcurrentModificationException: Cannot update record #X:Y in storage 'Z' because the version is not the latest. Probably you are updating an old record or...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found