Skip to content
Snippets Groups Projects
Commit a1a74aca authored by Erik Reid's avatar Erik Reid
Browse files

more redis current/next debug output

parent 24ff4c8f
No related branches found
No related tags found
No related merge requests found
......@@ -72,11 +72,15 @@ def latch_db(config):
def _get_redis(config, dbid=None):
if dbid is None:
logger.debug('no db specified, using minimum as first guess')
dbid = min(config['redis-databases'])
logger.debug(
'_get_redis[1], no db specified, '
'using minimum as first guess: {}'.format(dbid))
if dbid not in config['redis-databases']:
logger.error('tried to connect to unknown db id: {}'.format(dbid))
logger.error(
'_get_redis[2], tried to connect to unknown db id: {}, '
'using minimum: {}'.format(dbid, min(config['redis-databases'])))
dbid = min(config['redis-databases'])
kwargs = {
......@@ -106,8 +110,12 @@ def get_current_redis(config):
logger.warning("can't determine current db")
return r
if latch['this'] == latch['current']:
logger.debug(
'get_current_redis[1], using first latch: {}'.format(latch))
return r
else:
logger.debug(
'get_current_redis[2], using current latch: {}'.format(latch))
return _get_redis(config, latch['current'])
......@@ -115,13 +123,17 @@ def get_next_redis(config):
r = _get_redis(config)
latch = get_latch(r)
if latch and latch['this'] == latch['next']:
logger.debug('get_next_redis[1], using first latch: {}'.format(latch))
return r
if latch and latch['next'] in config['redis-databases']:
logger.debug('get_next_redis[2], using next latch: {}'.format(latch))
next_id = latch['next']
else:
logger.warning("next db not configured, deriving default value")
db_ids = sorted(set(config['redis-databases']))
next_id = db_ids[0] if len(db_ids) == 1 else db_ids[1]
logger.debug(
'get_next_redis[3], next db not configured, '
'derived next id: {}'.format(next_id))
return _get_redis(config, next_id)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment