-
Notifications
You must be signed in to change notification settings - Fork 22
ERROR: insert or update on table "instance" #181
Comments
We're still using Workflow for production work, and our Workflow tables are still in Oracle, so that's one difference. How did you construct your Workflow schema? It's possible there's a constraint in the Oracle schema that isn't present in your Postgres schema or in Workflow's metaDB. |
I noticed that your MetaDB is out of whack a bit. The constraint names still refer to the Oracle names. For example, Also, UR doesn't use the Have you just now updated to use a more recent UR? The table name change went out last summer. |
Our workflow schemas are re-constructed with the help of this schema-dump from TGI. Yes, we just updated to a new version of UR, it is this one. Should we just create a new MetaDB ? As you know the one we use right now is in this Is there a way to regenerate the Meta dump, I can then commit this back to that branch. |
Are your workflow tables in the same database as all the other Genome tables? If so, then you'll probably want to edit Workflow's MetaDB to minimize the damage the automated update tool might do. You can update the MetaDB with the automated tool like this: |
Running the
|
Then it looks like the MetaDB dump needs to be edited by hand. One simple thing you can try is to edit lib/Workflow/DataSource/Meta.sqlite3-dump and remove all the If that works and you want to be bothered to do it, we can edit the MetaDB dump to fix the table and constraint names. |
Sorry I should have mentioned, the previous error was after removing all the
Any idea what |
Sorry, I wasn't clear... I meant to remove all the INSERT statements from the MetaDB dump, then try re-running the build (or whatever generated the original FK constraint error). The error |
ok, thanks, that helps a lot :) this is completely uncharted territory for me 🎲 |
removing all the INSERT statements from |
I'm out of simple fixes. You could try reverting your UR checkout to You could try editing the MetaDB dump by hand. Change all the "owner" columns to empty strings and "table_name" to include the schema, like You could try stepping though the dependency-resolution code in UR::DataSource::RDBMS::_sync_database() and figure out why it's inserting things in the wrong order. |
Some helpful info from Tony to help us debug this, The class definition tells UR what database table to save to using the table_name attribute. When it's time to save, UR looks up a UR::DataSource::RDBMS::Table object (backed by the dd_table table in the MetaDB) that goes with that class's table. If it finds one, then it believes the MetaDB is the truth about that class's table, columns and constraints. If the Table object is not found, then UR asks the database what that table's columns and constraints look like, then creates a UR::DataSource::RDBMS::Table object (and associated Column and Constraint objects) that exist only during the life of the program - they're not saved to the MetaDB. UR then uses these MetaDB objects to determine what columns the table has in order to write the SQL for saving. It uses the FK constraint objects to determine the order to save to to satisfy the constraints. What I think is going on is there's a constraint in the DB to ensure the peer_instance_id column in the workflow_instance table also appears in that same table with the same workflow_instance_id. There's a record for the workflow_instance table in the MetaDB, so UR believes the MetaDB has the complete truth about the workflow_instance table. When it looks up the FK constraints in the MetaDB, it's not finding all the info it needs to satisfy the constraint in the DB; probably because it's looking up table_name "workflow.workflow_instance" when it's in the metaDB as "workflow_instance". You could verify this by running it with the env var UR_DBI_MONITOR_SQL=1 and look for a SELECT statement looking up something from the dd_table table filtered by table_name. One thing that doesn't make sense is that if it could find the Table MetaDB object, why can't it also find the FKConstraint objects?
The MetaDB is just another database, like all the other databases UR can talk to. In practice, changes to the MetaDB objects only happens with you run "ur update classes-from-db". When saving objects from other namespaces like Genome, it only loads or __define__s MetaDB objects, never changing them or creating them, so the MetaDB (and its dump) don't change. |
more info:
|
That second bullet point is backwards. If the If |
Hey @brummett, I was just syncing up with @malachig and @obigriffith on this. Wanted to jump in and help if possible. Just wanted to check on a few things to make sure my memory is correct:
Does that all sound correct? |
All of the above aside: the error is coming from DBD:Pg. This means there is an actual constraint in the db that is being violated. Not an issue with the metadata? The constraint was either created by the db init script for the sGMS, or made dynamically because of the class structure at some point. We could:
Thoughts? |
Hi Scott, the constraint is in the schema dump here - https://github.com/genome/gms/blob/ubuntu-12.04/setup/schema.psql#L3207 |
To test, connect to the database and run "drop constraint $name", and try to re-run the build. If that works, delete the constraint from that file so it isn't re-created. #3 you can ignore if all of this works. If the constraint re-appears, the property tied to the constraint should be set to 'is_optional => 1'.
|
On Sun, Mar 29, 2015 at 8:19 PM, Scott [email protected] wrote:
I'm out until Wednesday. If you don't have it figured out by then, I can -- Tony |
I tried two things,
|
Nice.
|
This might be related to #189 but closing this for now since the build succeeds. The PR was merged in here - genome/genome#602 Master seems to handle this differently with separate environment variables for each lock. We could choose to go that way in the future. |
The Pindel step in the somatic-variation workflow dies with this error,
This is a violation of the constraint - "instance_peer_instance_id_fkey".
Note - This constraint is absent in the latest schema dump, this might just be due to TGI having moved on from workflow to flow?
The text was updated successfully, but these errors were encountered: