std::lock_guard l(monc_lock);
_renew_subs();
}
+ version_t get_start(const std::string& what) const {
+ std::lock_guard l(monc_lock);
+ return sub.get_start(what);
+ }
bool sub_want(std::string what, version_t start, unsigned flags) {
std::lock_guard l(monc_lock);
return sub.want(what, start, flags);
auto get_subs() const {
return sub_new;
}
+ // get the requested start epoch for a subscription
+ // search first in "new" subs - subs that have not yet been sent
+ // but requested and going to be sent, then in "sent" subs.
+ // if not found, return 0
+ version_t get_start(const std::string& what) const {
+ if (auto i = sub_new.find(what); i != sub_new.end()) {
+ return i->second.start;
+ }
+ if (auto i = sub_sent.find(what); i != sub_sent.end()) {
+ return i->second.start;
+ }
+ return 0;
+ }
bool need_renew() const;
// change the status of "new" subscriptions to "sent"
void renewed();
ldout(cct, 3) << "handle_osd_map hmm, i want a full map, requesting"
<< dendl;
monc->sub_want("osdmap", 0, CEPH_SUBSCRIBE_ONETIME);
+ last_osdmap_request_time = ceph::coarse_mono_clock::now();
monc->renew_subs();
}
}
void Objecter::_maybe_request_map()
{
- last_osdmap_request_time = ceph::coarse_mono_clock::now();
// rwlock is locked
int flag = 0;
if (_osdmap_full_flag()
<< "_maybe_request_map subscribing (onetime) to next osd map" << dendl;
flag = CEPH_SUBSCRIBE_ONETIME;
}
+ last_osdmap_request_time = ceph::coarse_mono_clock::now();
epoch_t epoch = osdmap->get_epoch() ? osdmap->get_epoch()+1 : 0;
if (monc->sub_want("osdmap", epoch, flag)) {
monc->renew_subs();
if (num_homeless_ops || !toping.empty()) {
_maybe_request_map();
} else if (last_osdmap_request_time != ceph::coarse_mono_clock::time_point()) {
+ const epoch_t epoch = osdmap->get_epoch() ? osdmap->get_epoch() + 1 : 0;
auto now = ceph::coarse_mono_clock::now();
auto elapsed = now - last_osdmap_request_time;
auto stale_window = ceph::make_timespan(cct->_conf->objecter_tick_interval) * 2;
- if (elapsed > stale_window) {
+ auto exist_sub = monc->get_start("osdmap");
+ ldout(cct, 20) << __func__ << ": elapsed since last osdmap request "
+ << std::chrono::duration<double>(elapsed).count() << "s"
+ << ", stale_window "
+ << std::chrono::duration<double>(stale_window).count() << "s"
+ << ", epoch " << epoch
+ << ", monc->get_start(osdmap) " << exist_sub
+ << dendl;
+ // check that:
+ // 1) we passed stale_window since last request AND
+ // 2) we don't have any osdmap subscription in flight OR
+ // we have subscription - but the epoch we need is newer than the one we subscribed for
+ if (elapsed > stale_window &&
+ ((exist_sub == 0) || (epoch > exist_sub))) {
double elapsed_s = std::chrono::duration<double>(elapsed).count();
double thresh_s = std::chrono::duration<double>(stale_window).count();
- ldout(cct, 10) << __func__ << ": osdmap stale: " << elapsed_s
+ ldout(cct, 20) << __func__ << ": osdmap stale: " << elapsed_s
<< "s > " << thresh_s << "s, maybe requesting map" << dendl;
_maybe_request_map();
}