JanusGraph / JanusGraph/janusgraph

CompositeIndex‘s unique fail

Open
#1,107 3 comments 0 reactions 0 assignees View on GitHub
kind/question
Dominant language
Java
Stars
5.8k
Forks
1.2k
Avg merge
13h 53m
Merged PRs (30d)
6

Description

**description: First, I create unique CompositeIndex. Then, Two terminas execute g.addV().property("name", "user2"). It's success. It's should be fail.**

- schema
```
graph = JanusGraphFactory.open("conf/graph1.properties")
m = graph.openManagement();
m.makePropertyKey('name').dataType(String.class).make()
m.commit()

m = graph.openManagement();
m.buildIndex('idx1_name', Vertex.class).addKey(m.getPropertyKey('name')).unique().buildCompositeIndex()
m.commit()
graph.tx().commit()

```
- termina1
```
gremlin> graph = JanusGraphFactory.open("conf/graph1.properties")
==>standardjanusgraph[hbase:[127.0.0.1]]
gremlin> g=graph.traversal()
==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1]], standard]

gremlin> g.addV().property("name", "user2")
==>v[8192]
gremlin> g.tx().commit()
==>null
gremlin> g.V().valueMap(true)
==>[id:4096,name:[user3],label:user]
==>[id:8192,name:[user2],label:vertex]
==>[id:4112,label:vertex]
==>[id:8208,name:[user1],label:vertex]
==>[id:4192,name:[user3],label:user]
==>[id:4304,name:[user2],label:vertex]

```

- termina2
```
gremlin> graph = JanusGraphFactory.open("conf/graph1.properties")
==>standardjanusgraph[hbase:[127.0.0.1]]
gremlin> g=graph.traversal()
==>graphtraversalsource[standardjanusgraph[hbase:[127.0.0.1]], standard]

gremlin> g.addV().property("name", "user2")
==>v[4304]
gremlin> g.tx().commit()
==>null
gremlin> g.V().valueMap(true)
==>[label:user,name:[user3],id:4096]
==>[label:vertex,name:[user2],id:8192]
==>[label:vertex,id:4112]
==>[label:vertex,name:[user1],id:8208]
==>[label:user,name:[user3],id:4192]
==>[label:vertex,name:[user2],id:4304]

gremlin> g.addV().property("name", "user2")
Adding this property for key [name] and value [user2] violates a uniqueness constraint [idx1_name]
Type ':help' or ':h' for help.
Display stack trace? [yN]
```

Contributor guide

Open the contributing guide

Research direction

Reproduce the behavior from the issue using graph.openManagement(), buildIndex(...).unique().buildCompositeIndex(), and two Gremlin sessions running g.addV().property("name", "user2") followed by commits. Trace how the composite index enforces uniqueness across those transactions; done means duplicate values are rejected consistently rather than committed by both terminals.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.