Replace deprecated SQLAlchemy "with_lockmode"
This method was deprecated in sqlalchemy 0.9 [1][2] and finally removed in version 1.4, which we'll be adopting very soon [3]. No end-user impact is expected, we're using a rudimentary form of the new "with_for_update" method. [1] https://docs.sqlalchemy.org/en/13/changelog/migration_09.html?highlight=with_lockmode#new-for-update-support-on-select-query [2] https://docs.sqlalchemy.org/en/13/orm/query.html#sqlalchemy.orm.query.Query.with_lockmode [3] http://lists.openstack.org/pipermail/openstack-discuss/2021-April/022094.html Change-Id: I0a3a89bd0741f6f91c39baaa68149551d8f4ce54 Partial-Bug: #1926399 Signed-off-by: Goutham Pacha Ravi <gouthampravi@gmail.com>
This commit is contained in:
parent
37c43a1201
commit
cadfe04b1f
|
@ -943,7 +943,7 @@ def _get_share_type_quota_usages(context, session, project_id, share_type_id):
|
|||
).filter(
|
||||
models.QuotaUsage.project_id == project_id,
|
||||
models.QuotaUsage.share_type_id == share_type_id,
|
||||
).with_lockmode('update').all()
|
||||
).with_for_update().all()
|
||||
return {row.resource: row for row in rows}
|
||||
|
||||
|
||||
|
@ -955,7 +955,7 @@ def _get_user_quota_usages(context, session, project_id, user_id):
|
|||
filter_by(project_id=project_id).
|
||||
filter(or_(models.QuotaUsage.user_id == user_id,
|
||||
models.QuotaUsage.user_id is None)).
|
||||
with_lockmode('update').
|
||||
with_for_update().
|
||||
all())
|
||||
return {row.resource: row for row in rows}
|
||||
|
||||
|
@ -966,7 +966,7 @@ def _get_project_quota_usages(context, session, project_id):
|
|||
session=session).
|
||||
filter_by(project_id=project_id).
|
||||
filter(models.QuotaUsage.share_type_id is None).
|
||||
with_lockmode('update').
|
||||
with_for_update().
|
||||
all())
|
||||
result = dict()
|
||||
# Get the total count of in_use,reserved
|
||||
|
@ -1239,7 +1239,7 @@ def _quota_reservations_query(session, context, reservations):
|
|||
read_deleted="no",
|
||||
session=session).
|
||||
filter(models.Reservation.uuid.in_(reservations)).
|
||||
with_lockmode('update'))
|
||||
with_for_update())
|
||||
|
||||
|
||||
@require_context
|
||||
|
|
Loading…
Reference in New Issue