Multi-backend breaks because sqlalchemy objects
are shared between child backends.
When creating a new service (Base), call dispose
to reset the sqlalchemy object and connection.
Change-Id: I9d937c5b2fa850edc5523f26e031f59cad5a9e7e
Closes-Bug: #
1417018
IMPL = db_concurrency.TpoolDbapiWrapper(CONF, _BACKEND_MAPPING)
+###################
+
+def dispose_engine():
+ """Force the engine to establish new connections."""
+
+ # FIXME(jdg): When using sqlite if we do the dispose
+ # we seem to lose our DB here. Adding this check
+ # means we don't do the dispose, but we keep our sqlite DB
+ # This likely isn't the best way to handle this
+
+ if 'sqlite' not in IMPL.get_engine().name:
+ return IMPL.dispose_engine()
+ else:
+ return
+
+
###################
if not db_driver:
db_driver = CONF.db_driver
self.db = importutils.import_module(db_driver) # pylint: disable=C0103
+ self.db.dispose_engine()
facade = _create_facade_lazily()
return facade.get_session(**kwargs)
+
+def dispose_engine():
+ get_engine().dispose()
+
_DEFAULT_QUOTA_NAME = 'default'