Hard deleting instance does not take into account soft-deleted referential constraints

Bug #1830438 reported by Matt Riedemann
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
Medium
Matt Riedemann

Bug Description

The instance hard delete code is new in Train but has a bug noted here:

https://review.opendev.org/#/c/570202/8/nova/db/sqlalchemy/api.py@1804

The hard delete of the instance can fail if there are related soft-deleted records (like detached volumes [bdms]), because I hit this in a gate run of the cross-cell resize stuff:

http://paste.openstack.org/show/752057/

'Cannot delete or update a parent row: a foreign key constraint fails (`nova_cell2`.`block_device_mapping`, CONSTRAINT `block_device_mapping_instance_uuid_fkey` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`))') [SQL: 'DELETE FROM instances WHERE instances.uuid = %(uuid_1)s'] [parameters: {'uuid_1': '4b8a12c4-e28a-49cc-a681-236c1e8a174c'}]

Tags: db
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

Fix proposed to branch: master
Review: https://review.opendev.org/661398

Changed in nova:
assignee: nobody → Matt Riedemann (mriedem)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.opendev.org/661398
Committed: https://git.openstack.org/cgit/openstack/nova/commit/?id=0b92c7e741b5abb1df70cc1d3bb8f0d1989cf2f5
Submitter: Zuul
Branch: master

commit 0b92c7e741b5abb1df70cc1d3bb8f0d1989cf2f5
Author: Matt Riedemann <email address hidden>
Date: Fri May 24 17:08:20 2019 -0400

    Fix hard-delete of instance with soft-deleted referential constraints

    When hard-deleting an instance we first delete related records
    but the code was not taking into account soft-deleted related
    records which will result in the instance delete failing due to
    a referential constraint because soft-deleted records are not
    really deleted when it comes to table constraints.

    This fixes the issue by simply passing read_deleted='yes' to the
    related record model query in the hard delete path.

    The related unit test is updated to cover this scenario and a
    typo in that same test is also fixed here.

    Change-Id: I9fc5a9cc40ceffc450c1fde1df7fb36581e9cc94
    Closes-Bug: #1830438

Changed in nova:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/nova 20.0.0.0rc1

This issue was fixed in the openstack/nova 20.0.0.0rc1 release candidate.

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.