Deletion of artifact is not possible because of foreign constraint

Bug #1741726 reported by Kushal Agrawal
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Glare
In Progress
Undecided
Mike Fedosin

Bug Description

When created an artifact which has a string/Integer/Boolean as a field property. It is not possible while using MySql database to delete artifact because of foreign constraint failure. It fails with below error :

ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key constraint fails (`glare`.`glare_artifact_properties`, CONSTRAINT `glare_artifact_properties_ibfk_1` FOREIGN KEY (`artifact_id`) REFERENCES `glare_artifacts` (`id`))

Changed in glare:
assignee: nobody → Kushal Agrawal (kushal2605)
Revision history for this message
Mike Fedosin (mfedosin) wrote :

Emmm... I think the description is not fully correct. I tried to create an artifact on my devstack with dozens of custom fields of all types and then I was able to delete it without any issue.

Could you provide more details about how I can reproduce the bug?

Changed in glare:
status: New → Incomplete
Revision history for this message
Kushal Agrawal (kushal2605) wrote :

yes, I think I missed an important part of it. as it does not have any issue with sqllite. But there are issue with mysql database.

The issue is when we created database tables using alembic script we created foreign key using below command:

sa.Column('artifact_id', sa.String(36),
                  sa.ForeignKey('glare_artifacts.id'), nullable=False),

while creating we missed to provide parameter "ondelete='CASCADE'". without it in mysql it becomes as ondelete='RESTRICT' which is default value of it.

Now to drop and recreate the foreign key constraint we found that the name of the foreign-key-constraint is required which is getting decided by the database itself i.e. we do not have control over it. so right now we are not able to drop the constraint because of it. can you please suggest any way to do it?

Mike Fedosin (mfedosin)
Changed in glare:
status: Incomplete → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to glare (master)

Fix proposed to branch: master
Review: https://review.openstack.org/538018

Changed in glare:
assignee: Kushal Agrawal (kushal2605) → Mike Fedosin (mfedosin)
status: Confirmed → In Progress
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.