neo4j/neo4j — pull request #3733 by lutovich (2014-12-29 08:57:27+00:00)
Title: Use uniqueness constraint for start node lookup if possible

Now `MERGE` queries do not differentiate between simple index and uniqueness constraint for start node lookup. This results in locking strategy for start node, where locks on index entries are not grabbed. Such strategy can result in duplicated values in unique index. Non-unique lookup goes to kernel here: https://github.com/neo4j/neo4j/blob/2.1-maint/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java#L208 and unique lookup here: https://github.com/neo4j/neo4j/blob/2.1-maint/community/kernel/src/main/java/org/neo4j/kernel/impl/api/ConstraintEnforcingEntityOperations.java#L215. Method `ConstraintEnforcingEntityOperations#nodeGetUniqueFromIndexLookup` does smth similar to double-checked locking and acquires exclusive lock on unique index entry in result.
With this PR start node would be looked up in unique index, if such index exists.