JanusGraph / JanusGraph/janusgraph
Don't create unique index but got 'violates a uniqueness constraint'?
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 5.8k
- Forks
- 1.2k
- Avg merge
- 13h 53m
- Merged PRs (30d)
- 6
Description
using default docker-compose.yml in https://github.com/JanusGraph/janusgraph-docker
- Version: docker.io/janusgraph/janusgraph:latest
- Storage Backend: = berkeleyje
:> mgmt = graph.openManagement(); mgmt.getGraphIndexes(Vertex.class); return null. But in log
Stack Trace
2022/09/14 11:14:59 %!(EXTRA string=gremlinServerWSProtocol.responseHandler(), string=%!(EXTRA gremlingo.responseStatus={85 Adding this property for key [~T$SchemaName] and value [rtLateralMovement] violates a uniqueness constraint [SystemIndex#~T$SchemaName] map[exceptions:[org.janusgraph.core.SchemaViolationException] stackTrace:org.janusgraph.core.SchemaViolationException: Adding this property for key [~T$SchemaName] and value [rtLateralMovement] violates a uniqueness constraint [SystemIndex#~T$SchemaName]
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.addProperty(StandardJanusGraphTx.java:916)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.addProperty(StandardJanusGraphTx.java:838)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.addProperty(StandardJanusGraphTx.java:834)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.makeSchemaVertex(StandardJanusGraphTx.java:970)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.makePropertyKey(StandardJanusGraphTx.java:989)
at org.janusgraph.graphdb.types.StandardPropertyKeyMaker.make(StandardPropertyKeyMaker.java:114)
at org.janusgraph.core.schema.JanusGraphDefaultSchemaMaker.makePropertyKey(JanusGraphDefaultSchemaMaker.java:75)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.getOrCreatePropertyKey(StandardJanusGraphTx.java:1100)
at org.janusgraph.graphdb.transaction.StandardJanusGraphTx.getOrCreatePropertyKey(StandardJanusGraphTx.java:1089)
at org.janusgraph.graphdb.relations.AbstractTypedRelation.property(AbstractTypedRelation.java:130)
at org.apache.tinkerpop.gremlin.structure.util.ElementHelper.attachProperties(ElementHelper.java:287)
at org.janusgraph.graphdb.util.ElementHelper.attachProperties(ElementHelper.java:70)
at org.janusgraph.graphdb.vertices.AbstractVertex.addEdge(AbstractVertex.java:189)
at org.janusgraph.graphdb.vertices.AbstractVertex.addEdge(AbstractVertex.java:45)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeStep.map(AddEdgeStep.java:122)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.AddEdgeStep.map(AddEdgeStep.java:48)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.ScalarMapStep.processNextStart(ScalarMapStep.java:40)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:150)
at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:226)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.CoalesceStep.flatMap(CoalesceStep.java:58)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:49)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:150)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.ExpandableStepIterator.next(ExpandableStepIterator.java:55)
at org.apache.tinkerpop.gremlin.process.traversal.step.map.FlatMapStep.processNextStart(FlatMapStep.java:48)
at org.apache.tinkerpop.gremlin.process.traversal.step.util.AbstractStep.hasNext(AbstractStep.java:150)
at org.apache.tinkerpop.gremlin.process.traversal.util.DefaultTraversal.hasNext(DefaultTraversal.java:226)
at org.apache.tinkerpop.gremlin.server.op.AbstractOpProcessor.handleIterator(AbstractOpProcessor.java:97)
at org.apache.tinkerpop.gremlin.server.op.AbstractEvalOpProcessor.lambda$evalOpInternal$5(AbstractEvalOpProcessor.java:263)
at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:283)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)
]}, uint16=85))
Don't know how to reproduce.
Do some research: using :> mgmt = graph.openManagement();mgmt.printSchema() I found
Property Key Name | Cardinality | Data Type |
---------------------------------------------------------------------------------------------------
alert_id | SINGLE | class java.lang.String |
time | SINGLE | class java.lang.Long |
time | SINGLE | class java.lang.Long |
alert_id | SINGLE | class java.lang.String |
alert_id | SINGLE | class java.lang.String |
time | SINGLE | class java.lang.Long |
It have some same name Property Key Name . alert_id and time. They are property of edge by using addE(label).property(alert_id, id).time(time, 333)
Aslo id document https://docs.janusgraph.org/schema/
A JanusGraph schema can either be explicitly or implicitly defined
So If I only using gremlin language to addV or addE, I should not have such violates a uniqueness constraint error.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the stack-trace entry points in StandardJanusGraphTx.java, especially addProperty, makeSchemaVertex, and getOrCreatePropertyKey, then compare them with the schema behavior described in the linked schema documentation. Reproduce the default janusgraph-docker setup using BerkeleyJE and the reported addE property calls, inspecting output from mgmt.printSchema(). Done means identifying a reproducible cause or documenting why duplicate property keys trigger the uniqueness error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker-compose, java
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100