Database.max_retries only override on sqlalchemy side

Currently, the max_retries parameter will be override in
get_connection_from_config function. But it will be used
later in safe_mongo_call function.

Since the override of max_retries only need on sqlalchemy
side, this patch move the override from get_connection_
from_config to storage.impl_sqlalchemy.Connection.__init__
and make sure max_retries can be used on mongoDB side.

Change-Id: I83f35c886bc8b7299c1efd7297fdbc980214567f
Closes-Bug: #1395972
This commit is contained in:
lqslan 2014-11-25 12:35:37 +08:00
parent 942fb02a85
commit afb90e0cfc
2 changed files with 5 additions and 3 deletions

View File

@ -94,9 +94,6 @@ def get_connection_from_config(conf, purpose=None):
if purpose:
namespace = 'ceilometer.%s.storage' % purpose
url = getattr(conf.database, '%s_connection' % purpose) or url
# Set max_retries to 0, since oslo.db in certain cases may attempt to retry
# making the db connection retried max_retries ^ 2 times in failure case
conf.set_override('max_retries', 0, group='database')
return get_connection(url, namespace)

View File

@ -220,6 +220,11 @@ class Connection(base.Connection):
)
def __init__(self, url):
# Set max_retries to 0, since oslo.db in certain cases may attempt
# to retry making the db connection retried max_retries ^ 2 times
# in failure case and db reconnection has already been implemented
# in storage.__init__.get_connection_from_config function
cfg.CONF.set_override('max_retries', 0, group='database')
self._engine_facade = db_session.EngineFacade(
url,
**dict(cfg.CONF.database.items())