From de09aa254f647dc0dab0cd67c0ed26e093df180a Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Mon, 18 Feb 2013 04:00:38 +0000 Subject: Move DB thread pooling to DB API. The eventlet db_pool wrapping done in sqlalchemy is wrong. It needs to be around the whole DB API call. Fixes bug 1128605 Syncs nova with the fix in oslo. Moves nova to use the oslo version of db/api.py to import the DB API implementation. Renames configuration option sql_dbpool_enable to dbapi_use_tpool NOTE: tpool will not work without a fix to eventlet for Threads + locking. DocImpact Change-Id: I6c75b6138d38d12261d133f2cb2f5e59c667f837 --- nova/db/api.py | 11 +++++------ nova/db/sqlalchemy/api.py | 5 +++++ 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'nova/db') diff --git a/nova/db/api.py b/nova/db/api.py index e38cf1866..d14999b45 100644 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -47,14 +47,11 @@ from oslo.config import cfg from nova.cells import rpcapi as cells_rpcapi from nova import exception +from nova.openstack.common.db import api as db_api from nova.openstack.common import log as logging -from nova import utils db_opts = [ - cfg.StrOpt('db_backend', - default='sqlalchemy', - help='The backend to use for db'), cfg.BoolOpt('enable_new_services', default=True, help='Services to be added to the available pool on create'), @@ -69,8 +66,10 @@ db_opts = [ CONF = cfg.CONF CONF.register_opts(db_opts) -IMPL = utils.LazyPluggable('db_backend', - sqlalchemy='nova.db.sqlalchemy.api') +_BACKEND_MAPPING = {'sqlalchemy': 'nova.db.sqlalchemy.api'} + + +IMPL = db_api.DBAPI(backend_mapping=_BACKEND_MAPPING) LOG = logging.getLogger(__name__) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index d13c60969..360bd1b3a 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -78,6 +78,11 @@ get_engine = db_session.get_engine get_session = db_session.get_session +def get_backend(): + """The backend is this module itself.""" + return sys.modules[__name__] + + def require_admin_context(f): """Decorator to require admin request context. -- cgit