Segment updates may cause unnecessary overload

Bug #1952730 reported by Bence Romsics
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Fix Released
High
Bence Romsics

Bug Description

When:

* the segments service plugin is enabled and
* we have many rpc worker processes (as in the sum of rpc_workers and rpc_state_report_workers, since both kind processes agent state_reports) and
* many ovs-agents report physnets and
* neutron-server is restarted,

then rpc workers may get overloaded by state_report messages. That is: they may run at 100% CPU utilization for tens of minutes and during that they are not able process ovs-agent's state_reports in a timely manner. Which in turn causes the agent state to go down and back, maybe multiple times. Eventually, as the workers get through the initial processing, the load lessens, and the system stabilizes. The same rate of incoming state_report messages is not a problem at that point.

(Colleagues working downstream observed this on a stable/victoria base with cc 150 ovs-agents and 3 neutron-servers each having maybe rpc_workers=6 and rpc_state_report_workers=6. The relevant code did not change at all since victoria, so I believe the same would happen on master.)

I think the root cause is the following:

rabbitmq dispatches the state_report messages between the workers in a round robin fashion, terefore eventually the state_reports of the same agent will hit all rpc workers. Each worker has logic to update the host segment mapping if either the server or the agent got restarted:

https://opendev.org/openstack/neutron/src/commit/90b5456b8c11011c41f2fcd53a8943cb45fb6479/neutron/services/segments/db.py#L304-L305

Unfortunately the 'reported_hosts' set (to remember from which host the server has seen agent reports already) is private to each worker process. But right after a server (re-)start when that set is still empty, each worker will unconditionally write the received physnet-segment information into the db. This means we multiply the load on the db and rpc workers by a factor of the total rpc worker count.

Pushing a fix attempt soon.

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/+/819777

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

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

commit 176503e610aee16cb5799a77466579bc55129450
Author: Bence Romsics <email address hidden>
Date: Mon Nov 29 09:40:42 2021 +0100

    Avoid writing segments to the DB repeatedly

    When:
    * the segments service plugin is enabled and
    * we have multiple rpc worker processes (as in the sum of rpc_workers
      and rpc_state_report_workers, since both kind processes agent
      state_reports) and
    * many ovs-agents report physnets,
    then rabbitmq dispatches the state_report messages between the workers
    in a round robin fashion, therefore eventually the state_reports of the
    same agent will hit all rpc workers.

    Unfortunately all worker processes have a 'reported_hosts' set to
    remember from which host it has seen agent reports already. But right
    after a server start when that set is still empty, each worker will
    unconditionally write the received physnet-segment information into
    the db. This means we multiply the load on the db and rpc workers by
    a factor of the rpc worker count.

    This patch tries to reduce the load on the db by adding another early
    return before the unconditional db write.

    Change-Id: I935186b6ee95f0cae8dc05869d9742c8fb3353c3
    Closes-Bug: #1952730

Changed in neutron:
status: In Progress → Fix Released
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/+/821072

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/+/821073

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/+/821074

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

Reviewed: https://review.opendev.org/c/openstack/neutron/+/821073
Committed: https://opendev.org/openstack/neutron/commit/0c909e3b55c0f4d38647fa54882f8cbfd85f662a
Submitter: "Zuul (22348)"
Branch: stable/wallaby

commit 0c909e3b55c0f4d38647fa54882f8cbfd85f662a
Author: Bence Romsics <email address hidden>
Date: Mon Nov 29 09:40:42 2021 +0100

    Avoid writing segments to the DB repeatedly

    When:
    * the segments service plugin is enabled and
    * we have multiple rpc worker processes (as in the sum of rpc_workers
      and rpc_state_report_workers, since both kind processes agent
      state_reports) and
    * many ovs-agents report physnets,
    then rabbitmq dispatches the state_report messages between the workers
    in a round robin fashion, therefore eventually the state_reports of the
    same agent will hit all rpc workers.

    Unfortunately all worker processes have a 'reported_hosts' set to
    remember from which host it has seen agent reports already. But right
    after a server start when that set is still empty, each worker will
    unconditionally write the received physnet-segment information into
    the db. This means we multiply the load on the db and rpc workers by
    a factor of the rpc worker count.

    This patch tries to reduce the load on the db by adding another early
    return before the unconditional db write.

    Change-Id: I935186b6ee95f0cae8dc05869d9742c8fb3353c3
    Closes-Bug: #1952730
    (cherry picked from commit 176503e610aee16cb5799a77466579bc55129450)
    (cherry picked from commit dcb372b041a97121027706ca18c616adfc07d243)

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

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

commit dcb372b041a97121027706ca18c616adfc07d243
Author: Bence Romsics <email address hidden>
Date: Mon Nov 29 09:40:42 2021 +0100

    Avoid writing segments to the DB repeatedly

    When:
    * the segments service plugin is enabled and
    * we have multiple rpc worker processes (as in the sum of rpc_workers
      and rpc_state_report_workers, since both kind processes agent
      state_reports) and
    * many ovs-agents report physnets,
    then rabbitmq dispatches the state_report messages between the workers
    in a round robin fashion, therefore eventually the state_reports of the
    same agent will hit all rpc workers.

    Unfortunately all worker processes have a 'reported_hosts' set to
    remember from which host it has seen agent reports already. But right
    after a server start when that set is still empty, each worker will
    unconditionally write the received physnet-segment information into
    the db. This means we multiply the load on the db and rpc workers by
    a factor of the rpc worker count.

    This patch tries to reduce the load on the db by adding another early
    return before the unconditional db write.

    Change-Id: I935186b6ee95f0cae8dc05869d9742c8fb3353c3
    Closes-Bug: #1952730
    (cherry picked from commit 176503e610aee16cb5799a77466579bc55129450)

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

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

commit ed7bfa11ded509466a8d07ebe952c21621a22c2d
Author: Bence Romsics <email address hidden>
Date: Mon Nov 29 09:40:42 2021 +0100

    Avoid writing segments to the DB repeatedly

    When:
    * the segments service plugin is enabled and
    * we have multiple rpc worker processes (as in the sum of rpc_workers
      and rpc_state_report_workers, since both kind processes agent
      state_reports) and
    * many ovs-agents report physnets,
    then rabbitmq dispatches the state_report messages between the workers
    in a round robin fashion, therefore eventually the state_reports of the
    same agent will hit all rpc workers.

    Unfortunately all worker processes have a 'reported_hosts' set to
    remember from which host it has seen agent reports already. But right
    after a server start when that set is still empty, each worker will
    unconditionally write the received physnet-segment information into
    the db. This means we multiply the load on the db and rpc workers by
    a factor of the rpc worker count.

    This patch tries to reduce the load on the db by adding another early
    return before the unconditional db write.

    Change-Id: I935186b6ee95f0cae8dc05869d9742c8fb3353c3
    Closes-Bug: #1952730
    (cherry picked from commit 176503e610aee16cb5799a77466579bc55129450)
    (cherry picked from commit dcb372b041a97121027706ca18c616adfc07d243)
    (cherry picked from commit 0c909e3b55c0f4d38647fa54882f8cbfd85f662a)

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

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

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

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

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

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

tags: added: neutron-proactive-backport-potential
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/+/825734

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/+/825735

tags: removed: neutron-proactive-backport-potential
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (stable/ussuri)

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

commit 67190040113018fc955113640c2e7654a5a9cd5b
Author: Bence Romsics <email address hidden>
Date: Mon Nov 29 09:40:42 2021 +0100

    Avoid writing segments to the DB repeatedly

    When:
    * the segments service plugin is enabled and
    * we have multiple rpc worker processes (as in the sum of rpc_workers
      and rpc_state_report_workers, since both kind processes agent
      state_reports) and
    * many ovs-agents report physnets,
    then rabbitmq dispatches the state_report messages between the workers
    in a round robin fashion, therefore eventually the state_reports of the
    same agent will hit all rpc workers.

    Unfortunately all worker processes have a 'reported_hosts' set to
    remember from which host it has seen agent reports already. But right
    after a server start when that set is still empty, each worker will
    unconditionally write the received physnet-segment information into
    the db. This means we multiply the load on the db and rpc workers by
    a factor of the rpc worker count.

    This patch tries to reduce the load on the db by adding another early
    return before the unconditional db write.

    Change-Id: I935186b6ee95f0cae8dc05869d9742c8fb3353c3
    Closes-Bug: #1952730
    (cherry picked from commit 176503e610aee16cb5799a77466579bc55129450)
    (cherry picked from commit dcb372b041a97121027706ca18c616adfc07d243)
    (cherry picked from commit 0c909e3b55c0f4d38647fa54882f8cbfd85f662a)
    (cherry picked from commit ed7bfa11ded509466a8d07ebe952c21621a22c2d)

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

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

commit 7816ae3750b79a55d5e80daec9a93579d43ae94b
Author: Bence Romsics <email address hidden>
Date: Mon Nov 29 09:40:42 2021 +0100

    Avoid writing segments to the DB repeatedly

    When:
    * the segments service plugin is enabled and
    * we have multiple rpc worker processes (as in the sum of rpc_workers
      and rpc_state_report_workers, since both kind processes agent
      state_reports) and
    * many ovs-agents report physnets,
    then rabbitmq dispatches the state_report messages between the workers
    in a round robin fashion, therefore eventually the state_reports of the
    same agent will hit all rpc workers.

    Unfortunately all worker processes have a 'reported_hosts' set to
    remember from which host it has seen agent reports already. But right
    after a server start when that set is still empty, each worker will
    unconditionally write the received physnet-segment information into
    the db. This means we multiply the load on the db and rpc workers by
    a factor of the rpc worker count.

    This patch tries to reduce the load on the db by adding another early
    return before the unconditional db write.

    Depends-On: https://review.opendev.org/c/openstack/devstack/+/828769
    Change-Id: I935186b6ee95f0cae8dc05869d9742c8fb3353c3
    Closes-Bug: #1952730
    (cherry picked from commit 176503e610aee16cb5799a77466579bc55129450)
    (cherry picked from commit dcb372b041a97121027706ca18c616adfc07d243)
    (cherry picked from commit 0c909e3b55c0f4d38647fa54882f8cbfd85f662a)
    (cherry picked from commit ed7bfa11ded509466a8d07ebe952c21621a22c2d)

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

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

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

This issue was fixed in the openstack/neutron train-eol release.

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

This issue was fixed in the openstack/neutron ussuri-eol 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.