update_network_postcommit is being called from delete_network_precommit with an open session

Bug #1739798 reported by Daniel Alvarez
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Rodolfo Alonso

Bug Description

When a network is deleted, its segments are also deleted [0]. For each segment, it will notify about resources.SEGMENT and events.AFTER_DELETE [1] which will turn out in calling update_network_postcommit [2].

This should be avoided since drivers expect their postcommit methods to be called with no open sessions to the database. There should be separate callbacks for segments so that there's no transactions opened to the database in any of the postcommit calls.

We detected this in networking-ovn driver because we're attempting to bump revision numbers in a separate table in Neutron database when a network is updated but we can't commit that change to the database because there's already an open session on a network delete operation. This may be affecting other drivers as well.

[0] https://github.com/openstack/neutron/blob/6cdd079f8f3e6994734fa806b3c819cecb5f521a/neutron/services/segments/db.py#L315
[1] https://github.com/openstack/neutron/blob/6cdd079f8f3e6994734fa806b3c819cecb5f521a/neutron/services/segments/db.py#L178
[2] https://github.com/openstack/neutron/blob/6cdd079f8f3e6994734fa806b3c819cecb5f521a/neutron/plugins/ml2/plugin.py#L1917

description: updated
description: updated
Lujin Luo (luo-lujin)
tags: added: segment-callback-without-open-session
Lujin Luo (luo-lujin)
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 proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/neutron/+/852885

Changed in neutron:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

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

commit 3202a5c19ec01dfd38c4471be21002467bc0a0e5
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Wed Aug 10 12:02:50 2022 +0200

    [OVN] Remove session check in ``update_network_postcommit``

    Since [1], when a segment is deleted because the network is before,
    the segment event handler method ``_handle_segment_change`` does not
    call ``_notify_mechanism_driver_for_segment_change`` and thus the
    check performed in ``OVNMechanismDriver.update_network_postcommit``
    is not needed anymore.

    [1]https://review.opendev.org/c/openstack/neutron/+/786373

    Closes-Bug: #1739798
    Change-Id: I4bb22a0a0a233609a4d23af55a050356049eb214

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

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

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

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

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/854234
Committed: https://opendev.org/openstack/neutron/commit/1850646b412fedb073189619142d21fe1ce45e78
Submitter: "Zuul (22348)"
Branch: stable/xena

commit 1850646b412fedb073189619142d21fe1ce45e78
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Wed Aug 10 12:02:50 2022 +0200

    [OVN] Remove session check in ``update_network_postcommit``

    Since [1], when a segment is deleted because the network is before,
    the segment event handler method ``_handle_segment_change`` does not
    call ``_notify_mechanism_driver_for_segment_change`` and thus the
    check performed in ``OVNMechanismDriver.update_network_postcommit``
    is not needed anymore.

    [1]https://review.opendev.org/c/openstack/neutron/+/786373

    Conflicts:
        neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py

    Closes-Bug: #1739798
    Change-Id: I4bb22a0a0a233609a4d23af55a050356049eb214
    (cherry picked from commit 3202a5c19ec01dfd38c4471be21002467bc0a0e5)
    (cherry picked from commit 921d9a79aacf8529704b83ab64ab6167bb584f3c)

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/854233
Committed: https://opendev.org/openstack/neutron/commit/602c1025cd4104fe6ca87704427b09bdf7d11974
Submitter: "Zuul (22348)"
Branch: stable/yoga

commit 602c1025cd4104fe6ca87704427b09bdf7d11974
Author: Rodolfo Alonso Hernandez <email address hidden>
Date: Wed Aug 10 12:02:50 2022 +0200

    [OVN] Remove session check in ``update_network_postcommit``

    Since [1], when a segment is deleted because the network is before,
    the segment event handler method ``_handle_segment_change`` does not
    call ``_notify_mechanism_driver_for_segment_change`` and thus the
    check performed in ``OVNMechanismDriver.update_network_postcommit``
    is not needed anymore.

    [1]https://review.opendev.org/c/openstack/neutron/+/786373

    Conflicts:
        neutron/plugins/ml2/drivers/ovn/mech_driver/mech_driver.py

    Closes-Bug: #1739798
    Change-Id: I4bb22a0a0a233609a4d23af55a050356049eb214
    (cherry picked from commit 3202a5c19ec01dfd38c4471be21002467bc0a0e5)

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

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

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

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

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

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

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.