From: Yehuda Sadeh Date: Wed, 27 Apr 2016 22:09:55 +0000 (-0700) Subject: rgw: don't allow any concurrent sync requests on the same key X-Git-Tag: v10.2.1~44^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c08e90ea20b8ed96c7fe8638f725cf5abefc6783;p=ceph.git rgw: don't allow any concurrent sync requests on the same key We used to allow concurrent requests, as long as these had different op, which wasn't correct. Signed-off-by: Yehuda Sadeh (cherry picked from commit edea6d58dd25995bcc1ed4fc5be6f72ce4a6835a) --- diff --git a/src/rgw/rgw_data_sync.cc b/src/rgw/rgw_data_sync.cc index e65f37663f16..74e2498f24a8 100644 --- a/src/rgw/rgw_data_sync.cc +++ b/src/rgw/rgw_data_sync.cc @@ -1848,7 +1848,7 @@ class RGWBucketIncSyncShardMarkerTrack : public RGWSyncShardMarkerTrack > key_to_marker; + map key_to_marker; map 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);