neo4jrb / activegraph

An active model wrapper for the Neo4j Graph Database for Ruby.
http://neo4jrb.io
MIT License
1.39k stars 276 forks source link

DeprecatedSchemaDefinitionError despite migrations being fine #1644

Closed beechnut closed 3 years ago

beechnut commented 3 years ago

I'm getting ActiveGraph::DeprecatedSchemaDefinitionErrors nearly constantly, even though my migrations are in seemingly perfect working order.

I get this error about 10% of the time when I'm starting my app container, and I get it about 30% of the time when the app is under any sort of significant load (2–5 concurrent connections).

This is also the last issue between me and getting a working, performant app. If I can't find a solution to this, I'm planning to give up and start with another graph database. Even any information about how I might go about figuring out what's going on here will be massively appreciated—but I'll admit that I'm currently lost.

ActiveGraph::DeprecatedSchemaDefinitionError (          Some schema elements were defined by the model (which is no longer supported), but they do not exist in the database.  Run the following to create them if you haven't already:

rake neo4j:generate_schema_migration[constraint,ActiveGraph::Migrations::SchemaMigration,migration_id]
rake neo4j:generate_schema_migration[constraint,StructureLevel,uuid]

And then run `rake neo4j:migrate`

(zshell users may need to escape the brackets)
):

However, when I run rake neo4j:migrate:status, all of my migrations are fine, and the ones that are there cover the cases that the gem seems to think I need to change. The second and fourth migrations are actually duplicates, because it was the only way I could stop this error message from firing. (My data model has not changed.)

$ rake neo4j:migrate:status
Status     Migration ID         Migration Name
--------------------------------------------------
up         20201230183543       ForceCreateStructureLevelVersionDateConstraint
up         20210106222435       ForceCreateActiveGraphMigrationsSchemaMigrationMigrationIdConstraint
up         20210106222436       ForceCreateStructureLevelUuidConstraint
up         20210119233546       ForceCreateActiveGraphMigrationsSchemaMigrationMigrationIdConstraint

$ rake neo4j:migrate:status
Dumped updated schema file to db/neo4j/schema.yml

Questions

Runtime information:

Neo4j database version: 4.2.3 (Community) activegraph: 10.0.2 neo4j-ruby-driver: 1.7.4

klobuczek commented 3 years ago

@beechnut Wow, that's a very high caliber you are shooting. Changing the entire database because of some open-source framework bug? :) To start with: https://github.com/neo4jrb/activegraph#neo4j-version-support Not sure if this will solve all your issues but you need to use a supported version to troubleshoot any further. neo4j 4.2 is supported in beta version on jRuby only.

beechnut commented 3 years ago

@klobuczek Yeah, it's a new project and I was planning to try RedisGraph if I can't get past this persistent migration bug, since they also support Cypher.

Can't believe I missed a version graph so obvious and on the main page. Thanks for pointing me in the right direction!

beechnut commented 3 years ago

@klobuczek Following that chart, I've downgraded to Neo4j 4.0 and ActiveGraph 10.0.0, and I'm pretty consistently running into the same error, telling me I need to migrate constraints that already exist. I'm running out of ideas—I thought maybe the Neo4j server was out of RAM and throwing weird errors, but it's not even breaking 1GB.

Any ideas would be welcome.

ActiveGraph::DeprecatedSchemaDefinitionError (          Some schema elements were defined by the model (which is no longer supported), but they do not exist in the database.  Run the following to create them if you haven't already:
    rake neo4j:generate_schema_migration[constraint,ActiveGraph::Migrations::SchemaMigration,migration_id]
    rake neo4j:generate_schema_migration[constraint,StructureLevel,uuid]

And then run `rake neo4j:migrate`

Here are my 3 migrations, which cover the 2 migrations that are said to not exist:

$ rake neo4j:migrate:status
Status     Migration ID         Migration Name
--------------------------------------------------
up         20210204192009       ForceCreateActiveGraphMigrationsSchemaMigrationMigrationIdConstraint
up         20210204192015       ForceCreateStructureLevelUuidConstraint
up         20210204192020       ForceCreateStructureLevelVersionDateConstraint

If I follow the directions and re-generate those migrations, they generate identical files and when I try to migrate them, it throws errors that the constraint already exists:

Neo4j::Driver::Exceptions::DatabaseException: OnlineIndexProxy[accessor:org.neo4j.kernel.impl.index.schema.GenericNativeIndexAccessor@17c9449a, descriptor:Index( 2, 'constraint_6c0e5cd7', UNIQUE BTREE, :label[0](property[0]), native-btree-1.0 )] is ONLINE

Any thoughts?


And to add some complexity, when I'm running queries at any sort of load (even 2-5 requests/sec to my app, so maybe 10 queries/sec to the db), I get a combo of this error, RecordNotFound errors that say they can't find objects that have existed in the database for a while, and segfault errors from neo4j-ruby-driver.

RecordNotFound error:

ActiveGraph::Node::Labels::RecordNotFound (Couldn't find StructureLevel with 'uuid'="7ec577a8-733f-42f9-9f4c-786b2530bf3f"):

In the Neo4j browser, running MATCH (n:StructureLevel {uuid: "b4208bbd-93e4-4c16-a1af-adf74e645146"}) RETURN n; returns a valid record.

klobuczek commented 3 years ago

@beechnut if this is a new project you must be extremely overcomplicating. No migrations should be necessary. Ping me on neo4jrb gitter.

beechnut commented 3 years ago

It turns out that the bundle hadn't updated properly, so I was still unwittingly using mismatched versions. Downgrading to the aforementioned versions ended up resolving the issue.