[Openstack] Cleaning nova database

David Kranz david.kranz at qrclab.com
Tue Mar 20 15:43:06 UTC 2012


The users are using nova CLI, not euca. The 'deleted' field is already 
1. The delete fails because the id is a foreign key in the 
virtual_interfaces table. The question is how to excise an instance from 
the database without screwing anything up. Here is the whole row, which 
has a few unexpected values for a deleted instance, and the error. I am 
trying to determine if a bug should be filed. Of course I cannot 
reproduce this.

SQL query:

DELETE FROM `nova`.`instances` WHERE `instances`.`id` =155

MySQL said: Documentation
#1451 - Cannot delete or update a parent row: a foreign key constraint 
fails (`nova`.`virtual_interfaces`, CONSTRAINT 
`virtual_interfaces_ibfk_1` FOREIGN KEY (`instance_id`) REFERENCES 
`instances` (`id`))

   created_at: "2012-01-26 21:31:44"
   updated_at: "2012-02-27 22:35:24"
   deleted_at: "2012-02-27 22:35:35"
   deleted: 1
   id: 155
   user_id: "xxxxxxxxxxxxxxxxxx"
   project_id: "test"
   image_ref: 51
   kernel_id: 7
   ramdisk_id: ""
   launch_index: 0
   key_name: "li"
   key_data: "ssh-rsa 
AAAAB3NzaC1yc2EAAAADAQABAAAAgQCywTW0xypa949d2U5RBjTU9ip9yGapOy/9HwcRL5fgQh0EApVB5eUT7Pg3NgtB1AAVnsvNBguCRNmRzHwu2/kGc8AYNJEwgVGvR8eArrRltV7JriYxtC7/LirHM5EjdJ5paYKGOQAleb5fpfjlYuHd4H8RkYqcBRcriNzmGlJNPQ== 
nova at xg03\n"
   power_state: 5
   vm_state: "active"
   memory_mb: 2048
   vcpus: 1
   local_gb: 20
   hostname: "testworker2"
   host: "xg01"
   user_data: ""
   reservation_id: "r-u29wsnpn"
   launched_at: "2012-02-23 16:08:37"
   display_name: "testworker2"
   display_description: "testworker2"
   locked: 0
   launched_on: "xg01"
   instance_type_id: 5
   uuid: "36741362-b755-4aff-a6c4-7b292acfda0b"
   root_device_name: "/dev/vda"
   config_drive: ""
   task_state: "rebooting"
   default_local_device: "/dev/vdb"


On 3/20/2012 11:27 AM, Leandro Reox wrote:
> I think that the quick solution is set deteled to 1 on the offending 
> instances
>
> Are u using euca tools ? some inconsistencies are generated by them often
>
> Regards
> Lean
>
> On Tue, Mar 20, 2012 at 12:19 PM, David Kranz <david.kranz at qrclab.com 
> <mailto:david.kranz at qrclab.com>> wrote:
>
>     In a diablo/kvm cluster that has been running for a long time, a
>     user reported problems with some vms, tried rebooting them and
>     eventually deleted them. I recently noticed messages in the nova
>     compute log like: Found 13 in the database and 10 on the hypervisor.
>
>     Looking at the source code I understand that this means the
>     instances have been deleted as far as the hypervisor is concerned,
>     but nova still thinks they are there.
>     I found the offending instances in the database and they were
>     still listed as in the active state even though they
>     had a deletion date recorded. I tried to delete them but was
>     unable due to a foreign key error with virtual_interfaces. I could
>     play around with deleting various things from the database but
>     there are real users. Is their a documented way to "clean up" the
>     state of the nova database in such situations? It seems like a bug
>     that the database could get into this state.
>
>     Also, it seems that deleted instances are never removed from the
>     database. Is that a bug?
>
>      -David
>
>     _______________________________________________
>     Mailing list: https://launchpad.net/~openstack
>     <https://launchpad.net/%7Eopenstack>
>     Post to     : openstack at lists.launchpad.net
>     <mailto:openstack at lists.launchpad.net>
>     Unsubscribe : https://launchpad.net/~openstack
>     <https://launchpad.net/%7Eopenstack>
>     More help   : https://help.launchpad.net/ListHelp
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack/attachments/20120320/3f6f5f44/attachment.html>


More information about the Openstack mailing list