barbican/barbican/common
Dave McCowan 71829664b2 Fix Race Condition in get_or_create_project()
get_or_create_project() first calls a get (query of the database).
If that fails, then it calls create.  The issues is when
there are two threads and both fail the original get, then
each will call create.  One of those creates will fail, resulting
in the traceback.

One way to protect this critical region is to call create first,
then if that fails, call get.

In this case, get_or_create_project() is called for every
Barbican API operation.  The create action (which is slow), happens
once per project for the life of the cloud.  The get action happens
every other time.  For performance gains, I left call get first,
since that call succeeds almost always.

Change-Id: I2f13b495a6b45e226e0742291f76ee88dbcf52df
Closes-bug: #1726203
2017-10-22 22:19:26 -04:00
..
policies Merge "Put base policy rules at first" 2017-09-12 12:09:31 +00:00
__init__.py Files with no code must be left completely empty 2016-11-17 14:19:47 +08:00
config.py Remove translation of log messages 2017-06-03 10:18:55 +07:00
exception.py Trivial fix typos 2017-05-31 09:08:40 +07:00
hrefs.py Trivial fix typos 2017-05-31 09:08:40 +07:00
quota.py Remove unused logging import 2017-02-16 10:33:12 +07:00
resources.py Fix Race Condition in get_or_create_project() 2017-10-22 22:19:26 -04:00
utils.py Pick up general URI when constructing barbican endpoint 2017-09-12 15:11:11 +08:00
validators.py Remove translation of log messages 2017-06-03 10:18:55 +07:00