summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYehuda Sadeh <yehuda@inktank.com>2013-06-18 11:28:21 -0700
committerYehuda Sadeh <yehuda@inktank.com>2013-06-18 11:28:21 -0700
commitbfe4bf9d9dc66912c41609cb895ec673d4d03309 (patch)
treeb3d52bc3c820aaeff4222dd97debd8890495e124
parent2e27f69e04cb40684b68b85fe6145204f3409da3 (diff)
downloadceph-bfe4bf9d9dc66912c41609cb895ec673d4d03309.tar.gz
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 <yehuda@inktank.com>
-rw-r--r--src/rgw/rgw_rados.cc12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc
index dcbfae3e1cd..1c6595489eb 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)