IntegrityError while archiving if consoles are not deleted

Bug #1596933 reported by Abhishek Kekane on 2016-06-28
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Medium
Bhagyashri Shewale

Bug Description

On deleting the instance its associated console entries will not be deleted which will cause "IntegrityError" while archiving the deleted records from database.

1. Create an instance.

$ nova boot test-1 --flavor 1 --image cirros-0.3.4-x86_64-uec

2. Create an entry in console table manually with the above created instance_uuid.

insert into consoles (created_at, updated_at, instance_name, password, port, instance_uuid, deleted) values ('2016-06-15 06:00:13', '2016-06-15 06:00:13', 'test-1', '12345', 8080, '326757a3-66da-455f-8ffa-29775de1d5f5', 0);

3. Delete instance

$ nova delete 326757a3-66da-455f-8ffa-29775de1d5f5

4. Call db archive which raises following error

$ nova-manage db archive_deleted_rows 1000

2016-06-15 14:23:27.837 WARNING nova.db.sqlalchemy.api [-] IntegrityError detected when archiving table instances: (pymysql.err.IntegrityError) (1451, u'Cannot delete or update a parent row: a foreign key constraint fails (`nova`.`consoles`, CONSTRAINT `consoles_instance_uuid_fkey` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`))') [SQL: u'DELETE FROM instances WHERE instances.id in (SELECT T1.id FROM (SELECT instances.id \nFROM instances \nWHERE instances.deleted != %(deleted_1)s ORDER BY instances.id \n LIMIT %(param_1)s) as T1)'] [parameters: {u'param_1': 979, u'deleted_1': 0}]

Note:
I have added db entry manually as console service is not enabled in my environment.

Changed in nova:
assignee: nobody → Bhagyashri Shewale (bhagyashri-shewale)
tags: added: nova-manage

Steps to reproduce:

1. Create an instance.
$ nova boot test-1 --flavor 1 --image cirros-0.3.4-x86_64-uec

2. Create a console using api: /servers/{server_id}/consoles

3. Delete an instance
$ nova delete 326757a3-66da-455f-8ffa-29775de1d5f5

4. Call db archive which raises following error
$ nova-manage db archive_deleted_rows 1000

2016-06-15 14:23:27.837 WARNING nova.db.sqlalchemy.api [-] IntegrityError detected when archiving table instances: (pymysql.err.IntegrityError) (1451, u'Cannot delete or update a parent row: a foreign key constraint fails (`nova`.`consoles`, CONSTRAINT `consoles_instance_uuid_fkey` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`))') [SQL: u'DELETE FROM instances WHERE instances.id in (SELECT T1.id FROM (SELECT instances.id \nFROM instances \nWHERE instances.deleted != %(deleted_1)s ORDER BY instances.id \n LIMIT %(param_1)s) as T1)'] [parameters: {u'param_1': 979, u'deleted_1': 0}]

Sean Dague (sdague) on 2016-07-01
Changed in nova:
status: New → Confirmed
importance: Undecided → Medium

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

Changed in nova:
status: Confirmed → In Progress
tags: added: db
Matt Riedemann (mriedem) on 2016-09-14
tags: added: newton-backport-potential

Change abandoned by Matt Riedemann (<email address hidden>) on branch: master
Review: https://review.openstack.org/345191
Reason: This looks abandoned, and may already be fixed by change ceaf853894352b6d0ae12efe85ba5eb4e651e58a.

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers