HadoopMarc <m.c.d...@...>
toggle quoted message
Show quoted text
Hi Marc,
Sorry for slow reply, I missed the response notification (if one was sent). Anyways, I tried out your suggestion, and it seems like it might be an issue rather than just inconsistent behaviour. Details below:
gremlin> graph = JanusGraphFactory.build().set('storage.backend','hbase').set('storage.hbase.table','janusgraph').open() ==>standardjanusgraph[hbase:[127.0.0.1]] gremlin> gremlin> m=graph.openManagement() ==>org.janusgraph.graphdb.database.management.ManagementSystem@fe7b6b0 gremlin> vl=m.makeVertexLabel('system').partition().make() ==>system gremlin> pk=m.makePropertyKey('system_id').dataType(String.class).make() ==>system_id gremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk).indexOnly(vl).unique().buildCompositeIndex() ==>idx_system_id gremlin> m.commit() ==>null gremlin> g=graph.traversal() ==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1]], standard] gremlin> g.addV('system').property('system_id','A') ==>v[4226] gremlin> g.tx().commit() ==>null gremlin> g.addV('system').property('system_id','A') ==>v[8202] gremlin> g.tx().commit() ==>null gremlin> g.V() ==>v[8202] ==>v[4226] gremlin> g.V().properties() ==>vp[system_id->A] ==>vp[system_id->A]
On Friday, March 17, 2017 at 8:57:37 PM UTC, HadoopMarc wrote: Hi Ivan, When I first read your question on March 6 I thought this one was not for me, but I see now that you still did not get an answer. I agree it looks suspicious, but there is still one thing I would like you to try: in the first code block when you add the vertex for the second time, could you try a commit then? What may be the case is that you get an immediate error when a second identical vertex is added within the same transaction, but that you get a uniqueness error across transactions only at commit time of the second transaction. Cheers, Marc Op maandag 6 maart 2017 17:58:25 UTC+1 schreef Ivan Cikic: So, evaluating JanusGraph for a project, I ran into this: unique index on a Vertex property with a specific VertexLabel constraint doesn't seem to be respected across transactions? Or I'm just doing something wrong? Code snippet below should reproduce the issue.
plugin activated: janusgraph.imports plugin activated: tinkerpop.server plugin activated: tinkerpop.utilities plugin activated: tinkerpop.hadoop plugin activated: tinkerpop.spark plugin activated: tinkerpop.tinkergraph
gremlin> graph = JanusGraphFactory.build().set('storage.backend','hbase').set('storage.hbase.table','janusgraph').open() ==>standardjanusgraph[hbase:[127.0.0.1]] gremlin> m=graph.openManagement() ==>org.janusgraph.graphdb.database.management.ManagementSystem@541179e7 gremlin> vl=m.makeVertexLabel('system').partition().make() ==>system gremlin> pk=m.makePropertyKey('system_id').dataType(String.class).make() ==>system_id gremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk).indexOnly(vl).unique().buildCompositeIndex() ==>idx_system_id gremlin> m.commit() ==>null gremlin> g=graph.traversal() ==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1]], standard] gremlin> g.addV('system').property('system_id','A') ==>v[4226] <-- add Vertex: OK gremlin> g.tx().commit() ==>null gremlin> g.addV('system').property('system_id','A') ==>v[8202] <-- add Vertex with same property value: OK gremlin> g.addV('system').property('system_id','A') <-- add Vertex with same property value same TX: FAIL Adding this property for key [system_id] and value [A] violates a uniqueness constraint [idx_system_id]
Compared to this behaviour when using unique index without a VertexLabel constraint:
gremlin> graph = JanusGraphFactory.build().set('storage.backend','hbase').set('storage.hbase.table','janusgraph2').open() ==>standardjanusgraph[hbase:[127.0.0.1]] gremlin> m=graph.openManagement() ==>org.janusgraph.graphdb.database.management.ManagementSystem@27443560 gremlin> vl=m.makeVertexLabel('system').partition().make() ==>system gremlin> pk=m.makePropertyKey('system_id').dataType(String.class).make() ==>system_id gremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk).unique().buildCompositeIndex() <-- no indexOnly ==>idx_system_id gremlin> m.commit() ==>null gremlin> g=graph.traversal() ==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1]], standard] gremlin> g.addV('system').property('system_id','A') ==>v[4226] gremlin> g.addV('system').property('system_id','A') <-- add Vertex with same property value same TX: FAIL Adding this property for key [system_id] and value [A] violates a uniqueness constraint [idx_system_id] gremlin> g.tx().commit() ==>null gremlin> g.addV('system').property('system_id','A') <-- add Vertex with same property value new TX: FAIL Adding this property for key [system_id] and value [A] violates a uniqueness constraint [idx_system_id]
Thanks, Ivan
|