commit 71829664b2ac4547c54940ad62bd8d0123f6e422
Author: Dave McCowan <email address hidden>
Date: Sun Oct 22 22:19:26 2017 -0400
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.
Reviewed: https:/ /review. openstack. org/514103 /git.openstack. org/cgit/ openstack/ barbican/ commit/ ?id=71829664b2a c4547c54940ad62 bd8d0123f6e422
Committed: https:/
Submitter: Zuul
Branch: master
commit 71829664b2ac454 7c54940ad62bd8d 0123f6e422
Author: Dave McCowan <email address hidden>
Date: Sun Oct 22 22:19:26 2017 -0400
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: I2f13b495a6b45e 226e0742291f76e e88dbcf52df
Closes-bug: #1726203