Cannot update the record because the version is not the latest
See original GitHub issueHi,
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.
- 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();
}
}
- 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:
- Created 11 years ago
- Comments:47 (24 by maintainers)
Top GitHub Comments
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.
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