Merge PR #42943 into master

* refs/pull/42943/head:
	mon: do not quickly mark mds laggy when MON_DOWN
	mon: refactor quorum age calculation

Reviewed-by: Kefu Chai <kchai@redhat.com>
Reviewed-by: Ramana Raja <rraja@redhat.com>
This commit is contained in:
Patrick Donnelly 2021-09-15 22:36:18 -04:00
commit b1e8297fca
4 changed files with 36 additions and 8 deletions

View File

@ -764,6 +764,13 @@ options:
services:
- mon
with_legacy: true
- name: mds_beacon_mon_down_grace
type: secs
level: advanced
desc: tolerance in seconds for missed MDS beacons to monitors
fmt_desc: The interval without beacons before Ceph declares an MDS laggy
when a monitor is down.
default: 1_min
# skip safety assertions on FSMap (in case of bugs where we want to continue anyway)
- name: mon_mds_skip_sanity
type: bool

View File

@ -2136,6 +2136,11 @@ bool MDSMonitor::check_health(FSMap& fsmap, bool* propose_osdmap)
// check beacon timestamps
std::vector<mds_gid_t> to_remove;
const bool mon_down = mon.is_mon_down();
const auto mds_beacon_mon_down_grace =
g_conf().get_val<std::chrono::seconds>("mds_beacon_mon_down_grace");
const auto quorum_age = std::chrono::seconds(mon.quorum_age());
const bool new_quorum = quorum_age < mds_beacon_mon_down_grace;
for (auto it = last_beacon.begin(); it != last_beacon.end(); ) {
auto& [gid, beacon_info] = *it;
auto since_last = std::chrono::duration<double>(now-beacon_info.stamp);
@ -2152,6 +2157,14 @@ bool MDSMonitor::check_health(FSMap& fsmap, bool* propose_osdmap)
<< " (gid: " << gid << " addr: " << info.addrs
<< " state: " << ceph_mds_state_name(info.state) << ")"
<< " since " << since_last.count() << dendl;
if ((mon_down || new_quorum) && since_last < mds_beacon_mon_down_grace) {
/* The MDS may be sending beacons to a monitor not yet in quorum or
* temporarily partitioned. Hold off on removal for a little longer...
*/
dout(10) << "deferring removal for mds_beacon_mon_down_grace during MON_DOWN" << dendl;
++it;
continue;
}
// If the OSDMap is writeable, we can blocklist things, so we can
// try failing any laggy MDS daemons. Consider each one for failure.
if (!info.laggy()) {

View File

@ -2614,8 +2614,7 @@ void Monitor::_quorum_status(Formatter *f, ostream& ss)
if (!quorum.empty()) {
f->dump_int(
"quorum_age",
std::chrono::duration_cast<std::chrono::seconds>(
mono_clock::now() - quorum_since).count());
quorum_age());
}
f->open_object_section("features");
@ -2650,8 +2649,7 @@ void Monitor::get_mon_status(Formatter *f)
if (!quorum.empty()) {
f->dump_int(
"quorum_age",
std::chrono::duration_cast<std::chrono::seconds>(
mono_clock::now() - quorum_since).count());
quorum_age());
}
f->open_object_section("features");
@ -2990,7 +2988,6 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
const auto&& fs_names = session->get_allowed_fs_names();
mono_clock::time_point now = mono_clock::now();
if (f) {
f->dump_stream("fsid") << monmap->get_fsid();
healthmon()->get_health_status(false, f, nullptr);
@ -3006,8 +3003,7 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
f->close_section();
f->dump_int(
"quorum_age",
std::chrono::duration_cast<std::chrono::seconds>(
mono_clock::now() - quorum_since).count());
quorum_age());
}
f->open_object_section("monmap");
monmap->dump_summary(f);
@ -3061,7 +3057,7 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
const auto quorum_names = get_quorum_names();
const auto mon_count = monmap->mon_info.size();
ss << " mon: " << spacing << mon_count << " daemons, quorum "
<< quorum_names << " (age " << timespan_str(now - quorum_since) << ")";
<< quorum_names << " (age " << quorum_age() << ")";
if (quorum_names.size() != mon_count) {
std::list<std::string> out_of_q;
for (size_t i = 0; i < monmap->ranks.size(); ++i) {

View File

@ -216,6 +216,18 @@ public:
std::vector<DaemonHealthMetric> get_health_metrics();
int quorum_age() const {
auto age = ceph::mono_clock::now() - quorum_since;
return age.count();
}
bool is_mon_down() const {
int max = monmap->size();
int actual = get_quorum().size();
auto now = ceph::real_clock::now();
return actual < max && now > monmap->created.to_real_time();
}
// -- elector --
private:
std::unique_ptr<Paxos> paxos;