We've had some trouble with not clearing out subscription requests and
overloading the monitors (though only because of other bugs). Write a
helper for handling subscription requests that we can use to centralize
safety logic. Clear out the subscription whenever we get a map that covers
it; if there are more maps available than we received, we will issue another
subscription request based on "m->newest_map" at the end of handle_osd_map().
Notice that the helper will no longer request old maps which we already have,
and that unless forced it will not dispatch multiple subscribe requests
to a single monitor.
Skipping old maps is safe:
1) we only trim old maps when the monitor tells us to,
2) we do not send messages to our peers until we have updated our maps
from the monitor.
That means only old and broken OSDs will send us messages based on maps
in our past, and we can (and should) ignore any directives from them anyway.
Signed-off-by: Greg Farnum <greg@inktank.com>
Reviewed-by: Sage Weil <sage@inktank.com>
(cherry picked from commit
6db3ae851d1c936de045390d18b1c6ae95f2a209)
Conflicts:
src/osd/OSD.h
}
};
+void OSD::osdmap_subscribe(version_t epoch, bool force_request)
+{
+ OSDMapRef osdmap = service.get_osdmap();
+ if (osdmap->get_epoch() >= epoch)
+ return;
+
+ if (monc->sub_want_increment("osdmap", epoch, CEPH_SUBSCRIBE_ONETIME) ||
+ force_request) {
+ monc->renew_subs();
+ }
+}
+
void OSD::handle_osd_map(MOSDMap *m)
{
assert(osd_lock.is_locked());
return;
}
+ // even if this map isn't from a mon, we may have satisfied our subscription
+ monc->sub_got("osdmap", last);
+
// missing some?
bool skip_maps = false;
if (first > osdmap->get_epoch() + 1) {
Messenger *cluster_messenger;
Messenger *client_messenger;
- MonClient *monc;
+ MonClient *monc; // check the "monc helpers" list before accessing directly
PerfCounters *logger;
ObjectStore *store;
};
private:
+ /**
+ * @defgroup monc helpers
+ *
+ * Right now we only have the one
+ */
+
+ /**
+ * Ask the Monitors for a sequence of OSDMaps.
+ *
+ * @param epoch The epoch to start with when replying
+ * @param force_request True if this request forces a new subscription to
+ * the monitors; false if an outstanding request that encompasses it is
+ * sufficient.
+ */
+ void osdmap_subscribe(version_t epoch, bool force_request);
+ /** @} monc helpers */
+
// -- heartbeat --
/// information about a heartbeat peer
struct HeartbeatInfo {