From e6548ecd03bbf26db823016f59f405c105d5f134 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 11 Sep 2015 16:21:40 -0700 Subject: [PATCH] rgw: rearrange full metadata sync order Users need to exist before their buckets, better have bucket instances before bucket entry points Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_sync.cc | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index 6f4de500fab72..26769f3bfb305 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -1233,6 +1233,32 @@ public: req_ret(0), entries_index(NULL) { } + void append_section_from_set(set& all_sections, const string& name) { + set::iterator iter = all_sections.find(name); + if (iter != all_sections.end()) { + sections.push_back(name); + all_sections.erase(iter); + } + } + /* + * meta sync should go in the following order: user, bucket.instance, bucket + * then whatever other sections exist (if any) + */ + void rearrange_sections() { + set all_sections; + for (list::iterator iter = sections.begin(); iter != sections.end(); ++iter) { + all_sections.insert(*iter); + } + sections.clear(); + append_section_from_set(all_sections, "user"); + append_section_from_set(all_sections, "bucket.instance"); + append_section_from_set(all_sections, "bucket"); + + for (set::iterator iter = all_sections.begin(); iter != all_sections.end(); ++iter) { + sections.push_back(*iter); + } + } + int operate() { RGWRESTConn *conn = store->rest_master_conn; @@ -1247,6 +1273,7 @@ public: ldout(store->ctx(), 0) << "ERROR: failed to fetch metadata sections" << dendl; return set_state(RGWCoroutine_Error); } + rearrange_sections(); sections_iter = sections.begin(); for (; sections_iter != sections.end(); ++sections_iter) { yield { -- 2.39.5