]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: handle racing default region creation
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 18 Jun 2013 18:28:21 +0000 (11:28 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Tue, 18 Jun 2013 18:28:21 +0000 (11:28 -0700)
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 <yehuda@inktank.com>
src/rgw/rgw_rados.cc

index dcbfae3e1cd2172a52eff84b1c0f71476736eac1..1c6595489eb43e1c8fd97fa5a33d9e0da6237b48 100644 (file)
@@ -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)