]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Elector: Added sanity check for peer & ranks size
authorKamoltat <ksirivad@redhat.com>
Fri, 11 Feb 2022 17:17:58 +0000 (17:17 +0000)
committerKamoltat <ksirivad@redhat.com>
Tue, 31 May 2022 11:15:44 +0000 (11:15 +0000)
Check if ``peer >= ranks_size``, then we
remove the current peer from ``live_pinging`` sets,
incase the peer was already removed out of the quorum
but for some reason the Elector code didn't
get to update ``live_pinging`` and ``dead_pinging`` sets
in time with when ranks.size() of monmap is changed.
This is to prevent going into assertion error later at
MonMap.h:get_addrs().

Fixes: https://tracker.ceph.com/issues/50089
Signed-off-by: Kamoltat <ksirivad@redhat.com>
src/mon/Elector.cc

index 79b227a9c653024231127fdb3d696b4a5775942f..88ab16e9c6741d9565c1ec49efbb5e0895997e74 100644 (file)
@@ -491,6 +491,15 @@ void Elector::send_peer_ping(int peer, const utime_t *n)
 void Elector::ping_check(int peer)
 {
   dout(20) << __func__ << " to peer " << peer << dendl;
+
+  if (peer >= mon->monmap->ranks.size()) {
+    // Monitor no longer exists in the monmap,
+    // therefore, we shouldn't ping this monitor
+    // since we cannot lookup the address!
+    dout(20) << __func__ << "peer >= ranks_size" << dendl;
+    live_pinging.erase(peer);
+    return;
+  }
   if (!live_pinging.count(peer) &&
       !dead_pinging.count(peer)) {
     dout(20) << __func__ << peer << " is no longer marked for pinging" << dendl;
@@ -518,6 +527,7 @@ void Elector::ping_check(int peer)
 
 void Elector::begin_dead_ping(int peer)
 {
+  dout(20) << __func__ << " to peer " << peer << dendl;  
   if (dead_pinging.count(peer)) {
     return;
   }