Port deletion fails due to foreign key constraint

Bug #1930294 reported by Rodolfo Alonso
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Medium
Rodolfo Alonso

Bug Description

During a VM deletion, the port cannot be deleted with the following error: http://paste.openstack.org/show/805871/

2021-05-24 10:55:05.495 29 ERROR neutron.pecan_wsgi.hooks.translation oslo_db.exception.DBReferenceError: (pymysql.err.IntegrityError) (1451, 'Cannot delete or update a parent row: a foreign key constraint fails (`ovs_neutron`.`floatingips`, CONSTRAINT `floatingips_ibfk_1` FOREIGN KEY (`fixed_port_id`) REFERENCES `ports` (`id`))')
2021-05-24 10:55:05.495 29 ERROR neutron.pecan_wsgi.hooks.translation [SQL: DELETE FROM ports WHERE ports.id = %(id)s]

The referred port has a floating IP assigned that is concurrently deleted.

This error happens when the VM, created with Heat, is deleted.

More information about the deployment in https://bugzilla.redhat.com/show_bug.cgi?id=1963903.

Revision history for this message
Rodolfo Alonso (rodolfo-alonso-hernandez) wrote :

I think we should change the "floatingip" DB model definition. The "fixed_port" (the internal fixed IP port, attached to a VM) should be "viewonly" attribute to the "floatingip" object. From [1] (version 1.4, but I think you are using an older one, I need to check that once I have access):

"""
When set to True, the relationship is used only for loading objects, and not for any persistence operation. A relationship() which specifies relationship.viewonly can work with a wider range of SQL operations within the relationship.primaryjoin condition, including operations that feature the use of a variety of comparison operators as well as SQL functions such as cast(). The relationship.viewonly flag is also of general use when defining any kind of relationship() that doesn’t represent the full set of related objects, to prevent modifications of the collection from resulting in persistence operations.

When using the relationship.viewonly flag in conjunction with backrefs, the originating relationship for a particular state change will not produce state changes within the viewonly relationship. This is the behavior implied by relationship.sync_backref being set to False.
"""

That means a change in the viewed object ("port") won't produce changes in the backref ("floatingip").

Changed in neutron:
status: New → In Progress
Revision history for this message
Rodolfo Alonso (rodolfo-alonso-hernandez) wrote :
Hongbin Lu (hongbin.lu)
Changed in neutron:
importance: Undecided → Medium
Changed in neutron:
assignee: nobody → Rodolfo Alonso (rodolfo-alonso-hernandez)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/793369
Committed: https://opendev.org/openstack/neutron/commit/a98fe51b83440693f8acf17b157c38a944ef65ef
Submitter: "Zuul (22348)"
Branch: master

commit a98fe51b83440693f8acf17b157c38a944ef65ef
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu May 27 10:28:13 2021 +0000

    Set "floatingip.fixed_port" as viewonly

    Set "floatingip.fixed_port" attribute as
    viewonly. According to [1], "the originating relationship for a
    particular state change will not produce state changes within the
    viewonly relationship". That means any change on any of those ports
    won't change the backref and won't affect "floatingip" object.

    Closes-Bug: #1930294

    [1]https://docs.sqlalchemy.org/en/14/orm/relationship_api.html

    Change-Id: I202a12f82f70b1094cdb986ba404f396d5e0e427

Changed in neutron:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/wallaby)

Fix proposed to branch: stable/wallaby
Review: https://review.opendev.org/c/openstack/neutron/+/801337

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/victoria)

Fix proposed to branch: stable/victoria
Review: https://review.opendev.org/c/openstack/neutron/+/801338

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/ussuri)

Fix proposed to branch: stable/ussuri
Review: https://review.opendev.org/c/openstack/neutron/+/801339

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (stable/train)

Fix proposed to branch: stable/train
Review: https://review.opendev.org/c/openstack/neutron/+/801340

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/victoria)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/801338
Committed: https://opendev.org/openstack/neutron/commit/32f1dee278e84b4d6eee686dcc2165afb6361633
Submitter: "Zuul (22348)"
Branch: stable/victoria

commit 32f1dee278e84b4d6eee686dcc2165afb6361633
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu May 27 10:28:13 2021 +0000

    Set "floatingip.fixed_port" as viewonly

    Set "floatingip.fixed_port" attribute as
    viewonly. According to [1], "the originating relationship for a
    particular state change will not produce state changes within the
    viewonly relationship". That means any change on any of those ports
    won't change the backref and won't affect "floatingip" object.

    Closes-Bug: #1930294

    [1]https://docs.sqlalchemy.org/en/14/orm/relationship_api.html

    Change-Id: I202a12f82f70b1094cdb986ba404f396d5e0e427
    (cherry picked from commit a98fe51b83440693f8acf17b157c38a944ef65ef)

tags: added: in-stable-victoria
tags: added: in-stable-ussuri
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/ussuri)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/801339
Committed: https://opendev.org/openstack/neutron/commit/d8f1f1118d3cde0b5264220836a250f14687893e
Submitter: "Zuul (22348)"
Branch: stable/ussuri

commit d8f1f1118d3cde0b5264220836a250f14687893e
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu May 27 10:28:13 2021 +0000

    Set "floatingip.fixed_port" as viewonly

    Set "floatingip.fixed_port" attribute as
    viewonly. According to [1], "the originating relationship for a
    particular state change will not produce state changes within the
    viewonly relationship". That means any change on any of those ports
    won't change the backref and won't affect "floatingip" object.

    Closes-Bug: #1930294

    [1]https://docs.sqlalchemy.org/en/14/orm/relationship_api.html

    Change-Id: I202a12f82f70b1094cdb986ba404f396d5e0e427
    (cherry picked from commit a98fe51b83440693f8acf17b157c38a944ef65ef)

tags: added: in-stable-train
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/train)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/801340
Committed: https://opendev.org/openstack/neutron/commit/c1c4811401d05c5fab1c26ab7cf4a64310fb7c54
Submitter: "Zuul (22348)"
Branch: stable/train

commit c1c4811401d05c5fab1c26ab7cf4a64310fb7c54
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu May 27 10:28:13 2021 +0000

    Set "floatingip.fixed_port" as viewonly

    Set "floatingip.fixed_port" attribute as
    viewonly. According to [1], "the originating relationship for a
    particular state change will not produce state changes within the
    viewonly relationship". That means any change on any of those ports
    won't change the backref and won't affect "floatingip" object.

    Closes-Bug: #1930294

    [1]https://docs.sqlalchemy.org/en/14/orm/relationship_api.html

    Change-Id: I202a12f82f70b1094cdb986ba404f396d5e0e427
    (cherry picked from commit a98fe51b83440693f8acf17b157c38a944ef65ef)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/wallaby)

Reviewed: https://review.opendev.org/c/openstack/neutron/+/801337
Committed: https://opendev.org/openstack/neutron/commit/7119f1babd23338768765be0d6aad62e15cbb82d
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 7119f1babd23338768765be0d6aad62e15cbb82d
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Thu May 27 10:28:13 2021 +0000

    Set "floatingip.fixed_port" as viewonly

    Set "floatingip.fixed_port" attribute as
    viewonly. According to [1], "the originating relationship for a
    particular state change will not produce state changes within the
    viewonly relationship". That means any change on any of those ports
    won't change the backref and won't affect "floatingip" object.

    Closes-Bug: #1930294

    [1]https://docs.sqlalchemy.org/en/14/orm/relationship_api.html

    Change-Id: I202a12f82f70b1094cdb986ba404f396d5e0e427
    (cherry picked from commit a98fe51b83440693f8acf17b157c38a944ef65ef)

tags: added: in-stable-wallaby
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 16.4.1

This issue was fixed in the openstack/neutron 16.4.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 17.2.1

This issue was fixed in the openstack/neutron 17.2.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 18.1.1

This issue was fixed in the openstack/neutron 18.1.1 release.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/neutron 19.0.0.0rc1

This issue was fixed in the openstack/neutron 19.0.0.0rc1 release candidate.

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

Other bug subscribers