From: Casey Bodley Date: Thu, 27 Apr 2017 14:20:20 +0000 (-0400) Subject: rgw: use RGWShardCollectCR in MetaMasterTrimCR X-Git-Tag: v12.0.3~20^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=667ec9f3653cf40edcc475f66819684a26d77d61;p=ceph.git rgw: use RGWShardCollectCR in MetaMasterTrimCR limit the number of concurrent sync status requests to peers Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index e14f941a8f11..77b628e54d82 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -2596,6 +2596,40 @@ bool MetaMasterTrimShardCollectCR::spawn_next() return false; } +/// spawn rest requests to read each peer's sync status +class MetaMasterStatusCollectCR : public RGWShardCollectCR { + static constexpr int MAX_CONCURRENT_SHARDS = 16; + + MasterTrimEnv& env; + connection_map::iterator c; + std::vector::iterator s; + public: + MetaMasterStatusCollectCR(MasterTrimEnv& env) + : RGWShardCollectCR(env.store->ctx(), MAX_CONCURRENT_SHARDS), + env(env), c(env.connections.begin()), s(env.peer_status.begin()) + {} + + bool spawn_next() override { + if (c == env.connections.end()) { + return false; + } + static rgw_http_param_pair params[] = { + { "type", "metadata" }, + { "status", nullptr }, + { nullptr, nullptr } + }; + + ldout(cct, 20) << "query sync status from " << c->first << dendl; + auto conn = c->second.get(); + using StatusCR = RGWReadRESTResourceCR; + spawn(new StatusCR(cct, conn, env.http, "/admin/log/", params, &*s), + false); + ++c; + ++s; + return true; + } +}; + class MetaMasterTrimCR : public RGWCoroutine { MasterTrimEnv& env; rgw_meta_sync_status min_status; //< minimum sync status of all peers @@ -2619,34 +2653,12 @@ int MetaMasterTrimCR::operate() } ldout(cct, 10) << "fetching sync status for zone " << env.zone << dendl; - yield { - // query mdlog sync status from peers - rgw_http_param_pair params[] = { - { "type", "metadata" }, - { "status", nullptr }, - { nullptr, nullptr } - }; - - auto p = env.peer_status.begin(); - for (auto& c : env.connections) { - ldout(cct, 20) << "query sync status from " << c.first << dendl; - using StatusCR = RGWReadRESTResourceCR; - auto conn = c.second.get(); - spawn(new StatusCR(cct, conn, env.http, "/admin/log/", params, &*p), - false); - ++p; - } - } + // query mdlog sync status from peers + yield call(new MetaMasterStatusCollectCR(env)); // must get a successful reply from all peers to consider trimming - ret = 0; - while (ret == 0 && num_spawned()) { - yield wait_for_child(); - collect_next(&ret); - } if (ret < 0) { ldout(cct, 4) << "failed to fetch sync status from all peers" << dendl; - drain_all(); return set_cr_error(ret); } @@ -2856,8 +2868,8 @@ int MetaPeerTrimCR::operate() if (mdlog_info.realm_epoch > env.last_trim_epoch + 1) { // delete any prior mdlog periods - yield spawn(new PurgePeriodLogsCR(env.store, mdlog_info.realm_epoch, - &env.last_trim_epoch), true); + yield call(new PurgePeriodLogsCR(env.store, mdlog_info.realm_epoch, + &env.last_trim_epoch)); } else { ldout(cct, 10) << "mdlogs already purged through realm_epoch " << env.last_trim_epoch << dendl; @@ -2868,7 +2880,7 @@ int MetaPeerTrimCR::operate() yield { auto meta_mgr = env.store->meta_mgr; auto mdlog = meta_mgr->get_log(env.current.get_period().get_id()); - spawn(new MetaPeerTrimShardCollectCR(env, mdlog), true); + call(new MetaPeerTrimShardCollectCR(env, mdlog)); // ignore any errors during purge/trim because we want to hold the lock open } }