From: Yehuda Sadeh Date: Tue, 18 Jun 2013 18:28:21 +0000 (-0700) Subject: rgw: handle racing default region creation X-Git-Tag: v0.67-rc1~128^2~70 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bfe4bf9d9dc66912c41609cb895ec673d4d03309;p=ceph.git rgw: handle racing default region creation If region is not specified and there's no default region set we try to create a default region. However, we may race with another process trying to do the same, so we should handle that gracefully. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index dcbfae3e1cd2..1c6595489eb4 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -153,11 +153,17 @@ int RGWRegion::init(CephContext *_cct, RGWRados *_store, bool setup_region) int r = read_default(default_info); if (r == -ENOENT) { r = create_default(); + if (r == -EEXIST) { /* we may have raced with another region creation, + make sure we can read the region info and continue + as usual to make sure region creation is complete */ + ldout(cct, 0) << "create_default() returned -EEXIST, we raced with another region creation" << dendl; + r = read_info(name); + } if (r < 0) - return r; - r = set_as_default(); + return r; + r = set_as_default(); /* set this as default even if we weren't the creators */ if (r < 0) - return r; + return r; /*Re attempt to read region info from newly created default region */ r = read_default(default_info); if (r < 0)