Decorate only Flavor.get_* methods that execute queries
The get_* methods on the Flavor object use a common helper method to
build a query object to execute later.
Currently, the @api_db_api.context_manager.reader decorator which
manages the session is located on the helper method instead of on the
methods that actually execute the database queries. Part of the context
manager's job is to close the session after the query is executed.
Because the decorator is not on the methods that actually execute the
queries, those database connections are not being closed and it will
eventually lead to errors like:
sqlalchemy.exc.TimeoutError: QueuePool limit of size 5 overflow 50
reached, connection timed out, timeout 30.00 (Background on this
error at: https://sqlalche.me/e/14/3o7r)
which means the connection pool size plus the overflow size has been
reached and the pool will block for a fixed period of time before
timing out and raising this error.
This removes the @api_db_api.context_manager.reader decorator from the
query build helper method and adds it to the Flavor.get_* methods that
execute the database queries.
Reviewed: https:/ /review. opendev. org/c/openstack /nova/+ /888513 /opendev. org/openstack/ nova/commit/ 9ae6240c92e212b 2fa96d5163f68ef 1b30ee03b7
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit 9ae6240c92e212b 2fa96d5163f68ef 1b30ee03b7
Author: melanie witt <email address hidden>
Date: Fri Jul 14 02:23:23 2023 +0000
Decorate only Flavor.get_* methods that execute queries
The get_* methods on the Flavor object use a common helper method to
build a query object to execute later.
Currently, the @api_db_ api.context_ manager. reader decorator which
manages the session is located on the helper method instead of on the
methods that actually execute the database queries. Part of the context
manager's job is to close the session after the query is executed.
Because the decorator is not on the methods that actually execute the
queries, those database connections are not being closed and it will
eventually lead to errors like:
sqlalchem y.exc.TimeoutEr ror: QueuePool limit of size 5 overflow 50 /sqlalche. me/e/14/ 3o7r)
reached, connection timed out, timeout 30.00 (Background on this
error at: https:/
which means the connection pool size plus the overflow size has been
reached and the pool will block for a fixed period of time before
timing out and raising this error.
This removes the @api_db_ api.context_ manager. reader decorator from the
query build helper method and adds it to the Flavor.get_* methods that
execute the database queries.
Closes-Bug: #2027755
Change-Id: I4bf83d1642b62a b103716aff6dae7 438646e2b31