There seems to be an issue when one wants to start Barbican with multiple secret stores enabled. When you start Barbican using Devstack which spawns 3 processes then Barbican might try to populate the SecretStores table in the database twice with the same data which leads to the failure that can be seen below.
The issue might be located here [1] as 1 process might read data from the database and see that the table is empty meanwhile there is a second process that is executing this line [2] and is about to populate the database. When process 1 reaches the same line, the table is already populated which leads to an error as it will try to populate it again.
[1] https://opendev.org/openstack/barbican/src/commit/2e89feed005437bf1bdbefb3311f7140f4010f28/barbican/plugin/util/multiple_backends.py#L145
[2] https://opendev.org/openstack/barbican/src/commit/2e89feed005437bf1bdbefb3311f7140f4010f28/barbican/plugin/util/multiple_backends.py#L192
Traceback (most recent call last):
File "/opt/stack/data/venv/bin/barbican-wsgi-api", line 52, in <module>
application = get_api_wsgi_script()
File "/opt/stack/barbican/barbican/api/app.py", line 118, in get_api_wsgi_script
application = deploy.loadapp('config:%s' % conf)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 248, in loadapp
return loadobj(APP, uri, name=name, **kw)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 273, in loadobj
return context.create()
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 741, in create
return self.object_type.invoke(self)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 131, in invoke
return fix_call(
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/util.py", line 61, in fix_call
val = callable(*args, **kw)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/urlmap.py", line 31, in urlmap_factory
app = loader.get_app(app_name, global_conf=global_conf)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 355, in get_app
return self.app_context(name=name, global_conf=global_conf).create()
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 741, in create
return self.object_type.invoke(self)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 200, in invoke
app = context.app_context.create()
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 741, in create
return self.object_type.invoke(self)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/loadwsgi.py", line 138, in invoke
return fix_call(context.object, context.global_conf, **context.local_conf)
File "/opt/stack/data/venv/lib/python3.10/site-packages/paste/deploy/util.py", line 61, in fix_call
val = callable(*args, **kw)
File "/opt/stack/barbican/barbican/api/app.py", line 85, in _wrapper
repositories.setup_database_engine_and_factory(
File "/opt/stack/barbican/barbican/model/repositories.py", line 116, in setup_database_engine_and_factory
_initialize_secret_stores_data()
File "/opt/stack/barbican/barbican/model/repositories.py", line 227, in _initialize_secret_stores_data
secret_store.get_manager()
File "/opt/stack/barbican/barbican/plugin/interface/secret_store.py", line 666, in get_manager
_SECRET_STORE = SecretStorePluginManager()
File "/opt/stack/barbican/barbican/plugin/interface/secret_store.py", line 570, in __init__
multiple_backends.sync_secret_stores(self)
File "/opt/stack/barbican/barbican/plugin/util/multiple_backends.py", line 194, in sync_secret_stores
secret_stores_repo.create_from(conf_store)
File "/opt/stack/barbican/barbican/model/repositories.py", line 425, in create_from
raise exception.ConstraintCheck(error=error_msg)
barbican barbican.common.exception.ConstraintCheck: A defined SQL constraint check failed: 'pymysql.err.IntegrityError 1062, "Duplicate entry \'S>
Fix proposed to branch: master /review. opendev. org/c/openstack /barbican/ +/901532
Review: https:/