neutron/neutron/db/quota
Rodolfo Alonso Hernandez 2dd3ffa271 Remove the expired reservations in a separate DB transaction
In "DbQuotaNoLockDriver", when a new reservation is being made,
first the expired reservations are removed. That guarantees the
freshness of the existing reservations.

In systems with high concurrency of operations, the
"DbQuotaNoLockDriver.make_reservation" method will be called in
parallel. The expired reservations removal implies a deletion
on the "reservation" table that could be executed by several
workers at the same time (in the same controller or not). That
could lead to a "DBDeadlock" exception if multiple workers want
to delete the same registers.

In case an API worker receives this exception, it should continue
as the expired reservations have been deleted by other worker. It
should not retry this operation.

If the reservations are not deleted, the quota engine will filter
out those expired reservations when counting the current number of
reservations [1][2][3]. That means even if in a particular request
the expired reservations are not deleted, these won't count in the
resource quota calculation.

The default reservation expiration timeout is set to 120 seconds
(as it should have been initially set) that is the default
expiration delta for a reservation since 2015.

[1]e99d9a9d06/neutron/quota/resource.py (L340)
[2]e99d9a9d06/neutron/db/quota/api.py (L226)
[3]e99d9a9d06/neutron/objects/quota.py (L100-L101)

Closes-Bug: #1954662
Change-Id: I8af6565d2537db7f0df2e8e567ea046a0a6e003a
2021-12-14 15:09:31 +00:00
..
__init__.py Add DB support for resource usage tracking 2015-07-26 15:26:10 -07:00
api.py Remove the expired reservations in a separate DB transaction 2021-12-14 15:09:31 +00:00
driver.py Check quota limits 2021-10-27 12:33:18 +00:00
driver_nolock.py Remove the expired reservations in a separate DB transaction 2021-12-14 15:09:31 +00:00
models.py Adds a unique index to quotas 2020-11-20 14:05:39 +08:00