OpenStack Block Storage (Cinder)
Go to file
Gorka Eguileor 95fcb50a42 Fix quota usage duplicate entries
Our current quota system has a race condition on reservations that only
happens when we are creating new entries in the quota_usages table.

We normally lock quota_usages rows using a SELECT ... FOR UPDATE query,
but that's only effective when the entries exist, and current code just
creates them and proceeds without a lock on them.

This, together with the table not having unique constraint means that we
can get duplicated entries and we can have one entry overwriting the
data written by another request.

The quota_usages table does soft deletes, so the project_id and resource
fields are not enough for a unique constraint, so we add a new column
called race_preventer so we can have a unique constraint with the
3 fields.

Additionally we have to make sure that we acquire the locks before doing
the reservation calculations or the syncs, so once we create any missing
entries we close the session and try to get the locks again.

With these 2 changes we'll avoid duplicated entries as well as avoid
getting our quota usage out of sync right from the start.

For the unique constraint part of the code there were 2 alternatives
(one was even used in an earlier patchset):

- Create a virtual/computed column for the Table that sets it to a fixed
  value when deleted_at is NULL and to NULL in any other case, then use
  this virtual/computed column together with project_id and resource
  fields for a unique constraint.

  This change was my preferred solution, but it requires bumping the
  SQLAlchemy version to 1.3.11 where the feature was added as computed
  columns [1] and in some DB engines requires a relatively new version,
  for example for PostgreSQL is only supported on version 12 or later.

- Set deleted_at to a non NULL value by default on creation, and make
  sure our code always uses the deleted field to filter values.

  This is a bit nasty, but it has the advantage of not requiring new DB
  fields, no DB data migrations for existing entries, and easy to
  rollback once we figure out the underlying issue (although it may
  require a DB data migration on rollback if we want to leave the
  deleted_at entry at NULL).

The decision to add a new field was because one of the alternatives is
kind of hacky and the other one depends on specific DBMS versions and
requires a SQLAlchemy version bump.

[1]: https://docs.sqlalchemy.org/en/13/core/defaults.html#computed-generated-always-as-columns

Closes-Bug: #1484343
Change-Id: I9000c16c5b3e6f313f02256a10cb4bc0a26379f7
(cherry picked from commit 1fb0767d88)
2021-04-05 06:21:23 +00:00
api-ref/source Merge "api-ref: Don't list HTTP 500 for backup create" 2021-03-19 22:09:11 +00:00
cinder Fix quota usage duplicate entries 2021-04-05 06:21:23 +00:00
contrib/block-box Add note that block-box is not supported 2020-01-10 08:37:54 -06:00
doc Add quota utils to cinder-manage 2021-04-01 12:08:13 +02:00
etc/cinder Delete TSM Backup driver 2020-11-03 18:53:39 +02:00
playbooks zuul: collect cinderlib logs from tempest node(s) only 2020-07-16 14:42:29 +02:00
rally-jobs Small doc updates: canonical URLs, rally doc, etc 2019-06-04 17:57:16 +02:00
releasenotes Fix quota usage duplicate entries 2021-04-05 06:21:23 +00:00
tools Merge "tox mypy: Call mypywrap.sh directly" 2021-02-19 21:26:28 +00:00
.coveragerc Update .coveragerc after the removal of openstack directory 2016-10-17 19:09:37 +05:30
.gitignore Add mypy tox env 2020-10-14 08:24:13 -04:00
.gitreview Update .gitreview for stable/wallaby 2021-03-26 10:21:43 +00:00
.pylintrc Pylint: Filter out cinder.objects and requests E1101 2019-02-21 13:28:44 -05:00
.stestr.conf Add .stestr.conf configuration 2017-10-10 00:46:42 +00:00
.zuul.yaml Merge "add openstack-python3-wallaby-jobs-arm64 job" 2021-03-20 07:49:56 +00:00
CONTRIBUTING.rst Ussuri contrib docs community goal 2020-03-05 14:11:48 -05:00
HACKING.rst Update HACKING document to match current checks 2020-04-17 15:09:13 +00:00
LICENSE Initial fork out of Nova. 2012-05-03 10:48:26 -07:00
README.rst Merge "Refactor README links" 2020-01-22 11:44:36 +00:00
bindep.txt bindep: Track qemu-img dependency 2020-08-19 15:00:35 +00:00
driver-requirements.txt Add ceph iscsi volume driver 2021-01-28 08:22:13 -05:00
lower-constraints.txt Use os-brick 4.3.1 2021-03-31 11:03:06 +00:00
mypy-files.txt mypy: annotate volume manager 2021-02-10 12:27:47 -05:00
reno.yaml Reno: Use customized template 2020-10-06 13:28:45 +02:00
requirements.txt Use os-brick 4.3.1 2021-03-31 11:03:06 +00:00
setup.cfg Add ceph iscsi volume driver 2021-01-28 08:22:13 -05:00
setup.py Cleanup py27 support 2020-04-17 14:47:10 +02:00
test-requirements.txt Use os-brick 4.3.0 2021-03-25 13:15:43 -04:00
tox.ini Update TOX_CONSTRAINTS_FILE for stable/wallaby 2021-03-26 10:21:50 +00:00

README.rst

OpenStack Cinder

image

OpenStack Cinder is a storage service for an open cloud computing service.

You can learn more about Cinder at:

Getting Started

If you'd like to run from the master branch, you can clone the git repo:

git clone https://opendev.org/openstack/cinder

If you'd like to contribute, please see the information in CONTRIBUTING.rst

You can raise bugs on Launchpad

Python client

Python Cinderclient