]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't return EEXIST on put_bucket_instance_info()
authorYehuda Sadeh <yehuda@redhat.com>
Mon, 14 Mar 2016 16:37:17 +0000 (09:37 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 14 Mar 2016 16:37:17 +0000 (09:37 -0700)
If we're exclusive it means that we're trying to create the object. If
it's already created, it means that we previously synced it through a
different code path (the object name is unique for this specific bucket
instance). In that case, don't fail, the metadata object has been created.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_rados.cc

index 3ccf54f97e44d4c7b0e0ecadb819e7593da5e91e..83ed902fc718dad31d9ef965d92cf1d0a3184aad 100644 (file)
@@ -10360,7 +10360,19 @@ int RGWRados::put_bucket_instance_info(RGWBucketInfo& info, bool exclusive,
 
   string key;
   get_bucket_instance_entry(info.bucket, key); /* when we go through meta api, we don't use oid directly */
-  return rgw_bucket_instance_store_info(this, key, bl, exclusive, pattrs, &info.objv_tracker, mtime);
+  int ret = rgw_bucket_instance_store_info(this, key, bl, exclusive, pattrs, &info.objv_tracker, mtime);
+  if (ret == -EEXIST) {
+    /* well, if it's exclusive we shouldn't overwrite it, because we might race with another
+     * bucket operation on this specific bucket (e.g., being synced from the master), but
+     * since bucket instace meta object is unique for this specific bucket instace, we don't
+     * need to return an error.
+     * A scenario where we'd get -EEXIST here, is in a multi-zone config, we're not on the
+     * master, creating a bucket, sending bucket creation to the master, we create the bucket
+     * locally, while in the sync thread we sync the new bucket.
+     */
+    ret = 0;
+  }
+  return ret;
 }
 
 int RGWRados::put_linked_bucket_info(RGWBucketInfo& info, bool exclusive, time_t mtime, obj_version *pep_objv,