0

I get this constraintViolationException with AWS Neptune when I tried to create a bunch of edges. The problem is that it does not tell which edge already exists. I add roughly 50 edges at once using script via java gremlin-driver.

Has anyone came across this kind of scenario ?

org.apache.tinkerpop.gremlin.driver.exception.ResponseException: {"requestId":"c1e55266-6fa9-44f6-91b3-74f08d227ffd","code":"ConstraintViolationException","detailedMessage":"Edge with id already exists: "}
Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38
samairtimer
  • 826
  • 2
  • 12
  • 28

1 Answers1

0

The database supports ACID transaction writes. So if your query attempts to create multiple edges, with user provided IDs, which have to be unique, the whole transaction will either work (and commit) or fail (and rollback). This error, as you noticed, is because at least one of the IDs you provided is already in use.

You have a couple of options.

  1. Change the query to more of a "create if not exist" pattern.
  2. Run a query to find out which of the IDs already exists, prior to trying to add them all.

In an upcoming release of Apache TinkerPop we are planning to add a merge step that will make this type of task easier. Until that time, one of the two options above is the way to go in general.

Kelvin Lawrence
  • 14,674
  • 2
  • 16
  • 38