]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: don't allow any concurrent sync requests on the same key 9017/head
authorYehuda Sadeh <yehuda@redhat.com>
Wed, 27 Apr 2016 22:09:55 +0000 (15:09 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Mon, 9 May 2016 23:00:14 +0000 (16:00 -0700)
We used to allow concurrent requests, as long as these had different op,
which wasn't correct.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit edea6d58dd25995bcc1ed4fc5be6f72ce4a6835a)

src/rgw/rgw_data_sync.cc

index e65f37663f166a493769dbb28f50cbdea193fbc7..74e2498f24a89a5c4c389b9eb976f40808d2f3d4 100644 (file)
@@ -1848,7 +1848,7 @@ class RGWBucketIncSyncShardMarkerTrack : public RGWSyncShardMarkerTrack<string,
   string marker_oid;
   rgw_bucket_shard_inc_sync_marker sync_marker;
 
-  map<rgw_obj_key, pair<RGWModifyOp, string> > key_to_marker;
+  map<rgw_obj_key, string> key_to_marker;
   map<string, rgw_obj_key> marker_to_key;
 
   void handle_finish(const string& marker) {
@@ -1891,23 +1891,18 @@ public:
    * Also, we should make sure that we don't run concurrent operations on the same key with
    * different ops.
    */
-  bool index_key_to_marker(const rgw_obj_key& key, RGWModifyOp op, const string& marker) {
+  bool index_key_to_marker(const rgw_obj_key& key, const string& marker) {
     if (key_to_marker.find(key) != key_to_marker.end()) {
       set_need_retry(key);
       return false;
     }
-    key_to_marker[key] = make_pair<>(op, marker);
+    key_to_marker[key] = marker;
     marker_to_key[marker] = key;
     return true;
   }
 
-  bool can_do_op(const rgw_obj_key& key, RGWModifyOp op) {
-    auto i = key_to_marker.find(key);
-    if (i == key_to_marker.end()) {
-      return true;
-    }
-
-    return (i->second.first == op);
+  bool can_do_op(const rgw_obj_key& key) {
+    return (key_to_marker.find(key) == key_to_marker.end());
   }
 };
 
@@ -2298,7 +2293,7 @@ int RGWBucketShardIncrementalSyncCR::operate()
         }
         ldout(sync_env->cct, 20) << "[inc sync] syncing object: " << bucket_name << ":" << bucket_id << ":" << shard_id << "/" << key << dendl;
         updated_status = false;
-        while (!marker_tracker->can_do_op(key, entry->op)) {
+        while (!marker_tracker->can_do_op(key)) {
           if (!updated_status) {
             set_status() << "can't do op, conflicting inflight operation";
             updated_status = true;
@@ -2312,7 +2307,7 @@ int RGWBucketShardIncrementalSyncCR::operate()
             }
           }
         }
-        if (!marker_tracker->index_key_to_marker(key, entry->op, cur_id)) {
+        if (!marker_tracker->index_key_to_marker(key, cur_id)) {
           set_status() << "can't do op, sync already in progress for object";
           ldout(sync_env->cct, 20) << __func__ << ": skipping sync of entry: " << cur_id << ":" << key << " sync already in progress for object" << dendl;
           marker_tracker->try_update_high_marker(cur_id, 0, entry->timestamp);