From: Casey Bodley Date: Mon, 23 Jan 2017 21:34:42 +0000 (-0500) Subject: rgw: peer trims mdlog shards up to master's oldest entry X-Git-Tag: v12.0.3~20^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=0557a79612504646e9f195cacff839e6ad050957;p=ceph.git rgw: peer trims mdlog shards up to master's oldest entry Signed-off-by: Casey Bodley --- diff --git a/src/rgw/rgw_sync.cc b/src/rgw/rgw_sync.cc index e9c748eb59b2..2112f7d0155b 100644 --- a/src/rgw/rgw_sync.cc +++ b/src/rgw/rgw_sync.cc @@ -2522,7 +2522,20 @@ struct MasterTrimEnv : public TrimEnv { } }; -using PeerTrimEnv = TrimEnv; +struct PeerTrimEnv : public TrimEnv { + /// last trim timestamp for each shard, only applies to current period's mdlog + std::vector last_trim_timestamps; + + PeerTrimEnv(RGWRados *store, RGWHTTPManager *http, int num_shards) + : TrimEnv(store, http, num_shards), + last_trim_timestamps(num_shards) + {} + + void set_num_shards(int num_shards) { + this->num_shards = num_shards; + last_trim_timestamps.resize(num_shards); + } +}; } // anonymous namespace @@ -2838,6 +2851,8 @@ int MetaPeerTrimCR::operate() ldout(cct, 4) << "failed to read mdlog info from master" << dendl; return set_cr_error(retcode); } + // use master's shard count instead + env.set_num_shards(mdlog_info.num_shards); if (mdlog_info.realm_epoch > env.last_trim_epoch + 1) { // delete any prior mdlog periods @@ -2847,6 +2862,16 @@ int MetaPeerTrimCR::operate() ldout(cct, 10) << "mdlogs already purged through realm_epoch " << env.last_trim_epoch << dendl; } + + // if realm_epoch == current, trim mdlog based on master's markers + if (mdlog_info.realm_epoch == env.current.get_epoch()) { + 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); + // ignore any errors during purge/trim because we want to hold the lock open + } + } return set_cr_done(); } return 0;