Re: Unique composite index with label constraint - issue?
HadoopMarc <m.c.d...@...>
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:
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.ManagementSyst em@541179e7
gremlin> vl=m.makeVertexLabel('system').partition().make()
==>system
gremlin> pk=m.makePropertyKey('system_id').dataType(String.class).ma ke()
==>system_id
gremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk).index Only(vl).unique().buildComposi teIndex()
==>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.ManagementSyst em@27443560
gremlin> vl=m.makeVertexLabel('system').partition().make()
==>system
gremlin> pk=m.makePropertyKey('system_id').dataType(String.class).ma ke()
==>system_id
gremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk).uniqu e().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