diff --git a/src/yb/master/master_cluster_service.cc b/src/yb/master/master_cluster_service.cc index 3c56add62273..862a09c47cfe 100644 --- a/src/yb/master/master_cluster_service.cc +++ b/src/yb/master/master_cluster_service.cc @@ -137,8 +137,14 @@ class MasterClusterServiceImpl : public MasterServiceBase, public MasterClusterI *entry->mutable_registration() = std::move(*ts_info.mutable_registration()); auto last_heartbeat = desc->LastHeartbeatTime(); if (last_heartbeat) { - entry->set_millis_since_heartbeat(narrow_cast( - MonoTime::Now().GetDeltaSince(last_heartbeat).ToMilliseconds())); + auto ms_since_heartbeat = MonoTime::Now().GetDeltaSince(last_heartbeat).ToMilliseconds(); + if (ms_since_heartbeat > std::numeric_limits::max()) { + LOG(DFATAL) << entry->instance_id().permanent_uuid() + << " has not heartbeated since " + << ms_since_heartbeat; + ms_since_heartbeat = std::numeric_limits::max(); + } + entry->set_millis_since_heartbeat(narrow_cast(ms_since_heartbeat)); } entry->set_alive(desc->IsLive()); desc->GetMetrics(entry->mutable_metrics());