From 6237acb316f3505aea6fbca53aca48bcd92bf994 Mon Sep 17 00:00:00 2001 From: Loic Dachary Date: Thu, 14 Aug 2014 10:49:45 +0200 Subject: [PATCH] rados.py: avoid CephManager creation race gevent may hold the rados.py thread when it has an opportunity. The if not hasattr(ctx, 'manager'): must therefore be immediately before the manager creation it is supposed to protect. If any of the functions called as a side effect of first_mon = teuthology.get_first_mon(ctx, config) (mon,) = ctx.cluster.only(first_mon).remotes.iterkeys() give gevent an opportunity to hold the thread, it creates a race condition. The other possibility would be use a ctx lock to protect the code, but this solution seem simpler. http://tracker.ceph.com/issues/9027 Fixes: #9027 Signed-off-by: Loic Dachary --- tasks/rados.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/rados.py b/tasks/rados.py index 537deac0f25dc..3bc17cc8f5c64 100644 --- a/tasks/rados.py +++ b/tasks/rados.py @@ -142,9 +142,9 @@ def task(ctx, config): def thread(): """Thread spawned by gevent""" + first_mon = teuthology.get_first_mon(ctx, config) + (mon,) = ctx.cluster.only(first_mon).remotes.iterkeys() if not hasattr(ctx, 'manager'): - first_mon = teuthology.get_first_mon(ctx, config) - (mon,) = ctx.cluster.only(first_mon).remotes.iterkeys() ctx.manager = CephManager( mon, ctx=ctx, -- 2.39.5