Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dropping/creating constraints in one transaction #227

Closed
knirirr opened this issue Feb 16, 2023 · 1 comment
Closed

Dropping/creating constraints in one transaction #227

knirirr opened this issue Feb 16, 2023 · 1 comment

Comments

@knirirr
Copy link

knirirr commented Feb 16, 2023

I ended up finding #213 whilst looking into a problem with Rails migrations hanging:

== 20230131114605 ForceCreateNeo4jFairsharingRecordUuidConstraint: running... ==
 CYPHER SHOW CONSTRAINTS YIELD * WHERE type = $type AND labelsOrTypes = $labels AND properties = $properties | {:type=>"UNIQUENESS", :labels=>[:"Neo4j::FairsharingRecord"], :properties=>[:uuid]}
 CYPHER DROP CONSTRAINT constraint_93c26f8d
 CYPHER CREATE CONSTRAINT FOR (n:`Neo4j::FairsharingRecord`) REQUIRE n.`uuid` IS UNIQUE

...and at this point, ^C is necessary.
In the logs I see the following:

2023-01-31 11:46:17.672+0000 ERROR [o.n.b.p.c.f.StateMachineSPIImpl] Client triggered an unexpected error [Neo.DatabaseError.Statement.ExecutionFailed]: T
rying to create constraint 'constraint_93c26f8d' in same transaction as dropping 'constraint_93c26f8d'. This is not supported because they are both backed
 by similar indexes. Please drop constraint in a separate transaction before creating the new one., reference ac940772-c3c0-4d0e-a251-e8f84a41d454.

Dropping the constraint via a Neo4j console in the browser and re-running migrations eventually worked around the issue.

Ruby: 3.1.2p20
Rails: 7.0.4.2
Neo4j version 5.4.0-1
Neo4j ruby driver version: 4.4.3

@klobuczek
Copy link
Member

Yes, this behavior is enforced by neo4j server. The driver correctly passes the error through its api. In the migration, you should disable transactions so every query is executed in its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants