orientdb-gremlin icon indicating copy to clipboard operation
orientdb-gremlin copied to clipboard

How Transactions Affect IDs

Open fppt opened this issue 9 years ago • 5 comments

Hello Again,

I have another problem. The following code fails:

final String labelVertex = "VertexLabel";
OrientGraph graph = new OrientGraphFactory("memory:myGraph").getNoTx();
Vertex v1 = graph.addVertex(labelVertex);
graph.tx().commit();

v1 = graph.traversal().V().next();
Vertex v2 = graph.addVertex(labelVertex);

GraphTraversal<Vertex, Edge> traversal =graph.traversal().V(v2.id()).outE().as("edge").otherV().hasId(v2).select("edge");
traversal.hasNext();

but if I change graph.tx().commit(); to graph.commit(); it works.

The reason appears to be that the former approach results in v2 having a temporary negative id of -2, while the latter approach appears to result in a normal id.

The negative id results in the traversal failing. Is this intentional ? Can someone explain why the one approach assigns temporary negative ids after commit while the other approach doesn't ?

fppt avatar Sep 12 '16 15:09 fppt

I have the same issue: I get IDs with :-2. The gremlin step "hasId" fails with these IDs:

INFO: $ANSI{green {db=test-0.32134751615175705}} Error during db request
com.orientechnologies.orient.core.sql.OCommandSQLParsingException: Error parsing query:
SELECT FROM `V_MyClass`  WHERE   `~id` = :~id
                                      ^
Encountered "" at line 1, column 35.
Was expecting one of:
    
	DB name="test-0.32134751615175705"
	Error Code="1"
	at com.orientechnologies.orient.core.sql.parser.OStatementCache.throwParsingException(OStatementCache.java:140)
	at com.orientechnologies.orient.core.sql.parser.OStatementCache.parse(OStatementCache.java:132)
	at com.orientechnologies.orient.core.sql.parser.OStatementCache.get(OStatementCache.java:81)
	at com.orientechnologies.orient.core.sql.parser.OStatementCache.get(OStatementCache.java:63)
	at com.orientechnologies.orient.core.sql.OSQLEngine.parse(OSQLEngine.java:71)
	at com.orientechnologies.orient.core.db.document.ODatabaseDocumentEmbedded.command(ODatabaseDocumentEmbedded.java:563)
	at org.apache.tinkerpop.gremlin.orientdb.OrientGraph.lambda$querySql$4(OrientGraph.java:271)
	at org.apache.tinkerpop.gremlin.orientdb.OrientGraph.executeWithConnectionCheck(OrientGraph.java:193)
	...

To-om avatar Jul 18 '18 21:07 To-om

Actually, my hasId problem is not related to this issue. HasId step fails with any string representation of ID.

To-om avatar Jul 19 '18 08:07 To-om

Hi @To-om

yes it is different. I see a problem on the generated query. Let me fix it

Thanks

wolf4ood avatar Jul 19 '18 09:07 wolf4ood

Hi @To-om

how can i reproduce this?

wolf4ood avatar Jul 19 '18 09:07 wolf4ood

I've created a dedicated issue (#150) with unit tests (#149)

To-om avatar Jul 19 '18 09:07 To-om