Currently, the query to quota usage table is not order
preserved. This might cause deadlock in large-scale
deployment: different calls may lock rows in different
order, and deadlock will happen.
This patch adds order_by to the query and make the query
to the table order preserved.
Change-Id: I7c439235f8927d5eb52274a59d0a87ad76879de1
Closes-bug: #
1552510
read_deleted="no",
session=session).\
filter_by(project_id=project_id).\
+ order_by(models.QuotaUsage.id.asc()).\
with_lockmode('update').\
all()
return {row.resource: row for row in rows}
deleted="no",
session=session).\
filter_by(resource=resource).\
+ order_by(models.QuotaUsage.id.asc()).\
with_lockmode('update').\
all()
return rows