]> 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>
Fri, 7 Oct 2022 15:11:37 +0000 (15:11 +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>
(cherry picked from commit fd8c9cf29e4f5f72b8723a999a69d6ca406e104b)

src/mon/Elector.cc

index 42be292d45146a3f14c1eca3c030243735825ea0..6f7fba553c9a868e1468b103b81a37418b51b6e2 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;
   }