apoc icon indicating copy to clipboard operation
apoc copied to clipboard

apoc.export.cypher.all violates unique constraint when rewriting nodes at the same time

Open neo-technology-build-agent opened this issue 2 years ago • 0 comments

Issue by Pils19 Monday Dec 10, 2018 at 09:27 GMT Originally opened as https://github.com/neo4j-contrib/neo4j-apoc-procedures/issues/1014


I was exporting a big graph to cypher with the following query.
call apoc.export.cypher.all(null {format:"plain",separateFiles:true,streamStatements:true,batchSize:100}) While i was exporting the graph there was heavy write on the graph that included deleting & recreating nodes that have an unique constraint on one property. I expected that the graph is exported as it is to the time where i started the export.

But when i tried to write the data to a fresh neo4j instance (order: nodes, schema, relations). I got an error when i tried to apply the schema opertations on the graph. The error is an neo4j.exceptions.DatabaseError: Unable to create CONSTRAINT ON [...] error. The graph was empty before. I checked the database on which the import failed and saw the following, there where about 10 nodes that are duplicated. All of these nodes were deleted and rewritten, while i was exporting the graph.

I would assume that there is no lock or something else while exporting? Which leads to duplicate node create queries on import?

  1. To reproduce the problem just create a big graph fill it with random data and read nodes, delete them, rewrite them randomly while exporting to cypher.
  2. Try to reimport the exported cypher queries to a fresh graph (order nodes, schema, relations). Error should occur.

Neo4j version: 3.4.9-enterprise (Docker) Neo4j-Apoc version: 3.4.0.4