Date
1 - 7 of 7
Unique composite index with label constraint - issue?
Ivan Cikic <ivan...@...>
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
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
Ivan Cikic <ivan...@...>
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@fe7b6b0gremlin> vl=m.makeVertexLabel('system').partition().make()==>systemgremlin> pk=m.makePropertyKey('system_id').dataType(String.class).make()==>system_idgremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk).indexOnly(vl).unique().buildCompositeIndex()==>idx_system_idgremlin> m.commit()==>nullgremlin> 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()==>nullgremlin> g.addV('system').property('system_id','A')==>v[8202]gremlin> g.tx().commit()==>nullgremlin> 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.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
HadoopMarc <m.c.d...@...>
Hi Ivan,
Do you want to post the issue yourself (on https://github.com/JanusGraph/janusgraph/issues) or do you want me to do it? The issue can refer to this thread. JanusGraph's source code contains a test with an index combining unique() and indexonly(), see:
https://github.com/JanusGraph/janusgraph/blob/4e1b92c22a6f2bcf2a097eb627efde2f49603fab/janusgraph-test/src/main/java/org/janusgraph/graphdb/JanusGraphTest.java
but the file has 5000 lines and it is not easy to see whether your case is covered.
Cheers, Marc
Op zaterdag 8 april 2017 11:41:09 UTC+2 schreef Ivan Cikic:
Do you want to post the issue yourself (on https://github.com/JanusGraph/janusgraph/issues) or do you want me to do it? The issue can refer to this thread. JanusGraph's source code contains a test with an index combining unique() and indexonly(), see:
https://github.com/JanusGraph/janusgraph/blob/4e1b92c22a6f2bcf2a097eb627efde2f49603fab/janusgraph-test/src/main/java/org/janusgraph/graphdb/JanusGraphTest.java
but the file has 5000 lines and it is not easy to see whether your case is covered.
Cheers, Marc
Op zaterdag 8 april 2017 11:41:09 UTC+2 schreef Ivan Cikic:
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() ==>systemgremlin> pk=m.makePropertyKey('system_id').dataType(String.class). make() ==>system_idgremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk). indexOnly(vl).unique(). buildCompositeIndex() ==>idx_system_idgremlin> m.commit()==>nullgremlin> 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()==>nullgremlin> g.addV('system').property('system_id','A') ==>v[8202]gremlin> g.tx().commit()==>nullgremlin> 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.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
Ted Wilmes <twi...@...>
Hello,
I think the issue may be related to the partitioned vertex label you've setup
vl=m.makeVertexLabel('system').partition().make()
I was suspicious that might be the cause and confirmed by removing the partition option and then rerunning your exact steps. The second addV produced the expected: "Adding this property for key [system_id] and value [A] violates a uniqueness constraint [idx_system_id]". It appears there is a bug related to uniqueness constraints and partitioned vertex labels.
--Ted
On Saturday, April 8, 2017 at 9:30:52 AM UTC-5, HadoopMarc wrote:
Hi Ivan,
Do you want to post the issue yourself (on https://github.com/JanusGraph/janusgraph/issues) or do you want me to do it? The issue can refer to this thread. JanusGraph's source code contains a test with an index combining unique() and indexonly(), see:
https://github.com/JanusGraph/janusgraph/blob/ 4e1b92c22a6f2bcf2a097eb627efde 2f49603fab/janusgraph-test/ src/main/java/org/janusgraph/ graphdb/JanusGraphTest.java
but the file has 5000 lines and it is not easy to see whether your case is covered.
Cheers, Marc
Op zaterdag 8 april 2017 11:41:09 UTC+2 schreef Ivan Cikic: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() ==>systemgremlin> pk=m.makePropertyKey('system_id').dataType(String.class). make() ==>system_idgremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk). indexOnly(vl).unique(). buildCompositeIndex() ==>idx_system_idgremlin> m.commit()==>nullgremlin> 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()==>nullgremlin> g.addV('system').property('system_id','A') ==>v[8202]gremlin> g.tx().commit()==>nullgremlin> 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.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
Ivan Cikic <ivan...@...>
Good catch. Yes, I can confirm the issue is only with partitioned vertices. I'll create an issue for it.
Cheers,
Ivan
On Sunday, April 9, 2017 at 3:33:35 PM UTC+1, Ted Wilmes wrote:
Hello,I think the issue may be related to the partitioned vertex label you've setupvl=m.makeVertexLabel('system').partition().make() I was suspicious that might be the cause and confirmed by removing the partition option and then rerunning your exact steps. The second addV produced the expected: "Adding this property for key [system_id] and value [A] violates a uniqueness constraint [idx_system_id]". It appears there is a bug related to uniqueness constraints and partitioned vertex labels.--Ted
On Saturday, April 8, 2017 at 9:30:52 AM UTC-5, HadoopMarc wrote:Hi Ivan,
Do you want to post the issue yourself (on https://github.com/JanusGraph/janusgraph/issues) or do you want me to do it? The issue can refer to this thread. JanusGraph's source code contains a test with an index combining unique() and indexonly(), see:
https://github.com/JanusGraph/janusgraph/blob/ 4e1b92c22a6f2bcf2a097eb627efde 2f49603fab/janusgraph-test/ src/main/java/org/janusgraph/ graphdb/JanusGraphTest.java
but the file has 5000 lines and it is not easy to see whether your case is covered.
Cheers, Marc
Op zaterdag 8 april 2017 11:41:09 UTC+2 schreef Ivan Cikic: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() ==>systemgremlin> pk=m.makePropertyKey('system_id').dataType(String.class). make() ==>system_idgremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk). indexOnly(vl).unique(). buildCompositeIndex() ==>idx_system_idgremlin> m.commit()==>nullgremlin> 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()==>nullgremlin> g.addV('system').property('system_id','A') ==>v[8202]gremlin> g.tx().commit()==>nullgremlin> 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.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
Ivan Cikic <ivan...@...>
https://github.com/JanusGraph/janusgraph/issues/206 created.
On Sunday, April 9, 2017 at 3:51:12 PM UTC+1, Ivan Cikic wrote:
Good catch. Yes, I can confirm the issue is only with partitioned vertices. I'll create an issue for it.Cheers,Ivan
On Sunday, April 9, 2017 at 3:33:35 PM UTC+1, Ted Wilmes wrote:Hello,I think the issue may be related to the partitioned vertex label you've setupvl=m.makeVertexLabel('system').partition().make() I was suspicious that might be the cause and confirmed by removing the partition option and then rerunning your exact steps. The second addV produced the expected: "Adding this property for key [system_id] and value [A] violates a uniqueness constraint [idx_system_id]". It appears there is a bug related to uniqueness constraints and partitioned vertex labels.--Ted
On Saturday, April 8, 2017 at 9:30:52 AM UTC-5, HadoopMarc wrote:Hi Ivan,
Do you want to post the issue yourself (on https://github.com/JanusGraph/janusgraph/issues) or do you want me to do it? The issue can refer to this thread. JanusGraph's source code contains a test with an index combining unique() and indexonly(), see:
https://github.com/JanusGraph/janusgraph/blob/ 4e1b92c22a6f2bcf2a097eb627efde 2f49603fab/janusgraph-test/ src/main/java/org/janusgraph/ graphdb/JanusGraphTest.java
but the file has 5000 lines and it is not easy to see whether your case is covered.
Cheers, Marc
Op zaterdag 8 april 2017 11:41:09 UTC+2 schreef Ivan Cikic: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() ==>systemgremlin> pk=m.makePropertyKey('system_id').dataType(String.class). make() ==>system_idgremlin> i=m.buildIndex('idx_system_id', Vertex.class).addKey(pk). indexOnly(vl).unique(). buildCompositeIndex() ==>idx_system_idgremlin> m.commit()==>nullgremlin> 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()==>nullgremlin> g.addV('system').property('system_id','A') ==>v[8202]gremlin> g.tx().commit()==>nullgremlin> 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.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