Skip to content

mon: Track and process pending pings after election - #62416

Merged
ljflores merged 1 commit into
ceph:mainfrom
kamoltat:wip-ksirivad-fix-connection-score
Apr 22, 2025
Merged

ljflores merged 1 commit into
ceph:mainfrom
kamoltat:wip-ksirivad-fix-connection-score

Conversation

@kamoltat

@kamoltat kamoltat commented Mar 20, 2025 •

Copy link
Copy Markdown
Member

NOTE:

#59248 is dependent on this PR as it uses the connection score feature and this PR solves some of the issues related to connection scores.

Problem:

Monitors stop pinging each other when quorum_mon_feature flag is empty. This happens when the monitor freshly starts up and never formed a quorum before, or when you restart the monitors in the cluster. Basically, Monitor startups.

This problem can easily be reproduced everytime.

Steps to reproduce:

  1. Start 3 MONs with connectivity election strategy
  2. Fail 1 mon.
  3. Restart all the monitors (including the down monitor)
  4. Observe that the connection scores of each monitor will tell you that not all monitors are alive. Which is not true because all 3 Monitors are in quorum.

What happened was during monitor startups,
quorum_mon_feature is empty and although
they all participated in the election,
when they hit the function begin_peer_ping,
some monitors if not all will not send ping
because of the emptry quorum_mon_feature flag.
Therefore, after the election the monitors will
have the wrong connection score. However,
this will get resolved in the next election
because now that quorum_mon_feature is populated
they will start pinging each other again, hence,
correct connectivity score.

Although the next election will resolve the bad scores,
this will impact features like Netsplit detection because
it relies on connectivity scores and the last thing we want to
do is report false positives to the user.

Solution:

In begin_peer_ping, instead of just returning out of the function when quorum_mon_feature is empty, we
keep track of the peers that we should ping once
the election is finished. In Monitor::win_election we process the pending pings by calling begin_peer_ping on each of the peers.

Additionally:

Improved loggings in Elector class such
that debugging the pinging process gets easier.

Fixes: https://tracker.ceph.com/issues/70587

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

@kamoltat
kamoltat requested a review from a team as a code owner March 20, 2025 16:05
@kamoltat
kamoltat requested a review from gregsfortytwo March 20, 2025 16:05
@kamoltat kamoltat self-assigned this Mar 20, 2025
@kamoltat

Copy link
Copy Markdown
Member Author

jenkins test make check

@kamoltat

Copy link
Copy Markdown
Member Author

jenkins test api

@rzarzynski rzarzynski left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically LGTM, just one question.

Comment thread src/mon/Elector.cc Resolved
Comment thread src/mon/Elector.cc Resolved
@kamoltat
kamoltat force-pushed the wip-ksirivad-fix-connection-score branch from 1842df7 to e9dd755 Compare April 1, 2025 18:27
@kamoltat

kamoltat commented Apr 1, 2025

Copy link
Copy Markdown
Member Author

@rzarzynski Just pushed the new changes

@kamoltat

kamoltat commented Apr 2, 2025

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

Comment thread src/mon/Elector.cc
peer_acked_ping[prank] = m->stamp;
} else{
dout(20) << "m->stamp <= previous_acked .. we don't report_live_connection" << dendl;
} else {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THX.

Comment thread src/mon/Elector.cc
// Check if quorum feature is not set and we are in
// STATE_INIT, STATE_PROBING, STATE_SYNCHRONIZING or STATE_ELECTING
if (mon->get_quorum_mon_features().empty() &&
(!mon->is_leader() && !mon->is_peon() && !mon->is_shutdown())) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK.

@rzarzynski

Copy link
Copy Markdown
Contributor

@gregsfortytwo: do you want to take the final look before merging?

@kamoltat

Copy link
Copy Markdown
Member Author

think we can just qa this @rzarzynski

Problem:

Monitors stop pinging each other when quorum_mon_feature
flag is empty. This happens when the monitor freshly starts
up and never formed a quorum before, or when you restart
the monitors in the cluster. Basically, Monitor startups.

This problem can easily be reproduced everytime.

Steps to reproduce:
1. Start 3 MONs with `connectivity` election strategy
2. Fail 1 mon.
3. Restart all the monitors (including the down monitor)
4. Observe that the connection scores of each monitor
will tell you that not all monitors are alive. Which
is not true because all 3 Monitors are in quorum.

What happened was during monitor startups,
quorum_mon_feature is empty and although
they all participated in the election,
when they hit the function begin_peer_ping,
some monitors if not all will not send ping
because of the emptry quorum_mon_feature flag.
Therefore, after the election the monitors will
have the wrong connection score. However,
this will get resolved in the next election
because now that quorum_mon_feature is populated
they will start pinging each other again, hence,
correct connectivity score.

Solution:
In begin_peer_ping, instead of just returning out of
the function when quorum_mon_feature is empty, we
keep track of the peers that we should ping once
the election is finished. In Monitor::win_election
and Monitor::lose_elections,
we process the pending pings by calling begin_peer_ping
on each of the peers (both peons and leader)

Additionally:
Improved loggings in Elector class such
that debugging the pinging process gets easier.

Fixes: https://tracker.ceph.com/issues/70587

Signed-off-by: Kamoltat Sirivadhna <[email protected]>

sd

Signed-off-by: Kamoltat Sirivadhna <[email protected]>
@kamoltat
kamoltat force-pushed the wip-ksirivad-fix-connection-score branch from e9dd755 to eadcb8c Compare April 17, 2025 03:01
@kamoltat

Copy link
Copy Markdown
Member Author

jenkins test make check

@gregsfortytwo

Copy link
Copy Markdown
Member

This seems fine at a glance, but I’m surprised that it makes the net split detection work by getting scores going more quickly.

I guess the real fix is because this makes sure all the monitors are in the active pinging state before a monitor election finishes, so they default to looking connected instead of unconnected on first check?

@kamoltat

Copy link
Copy Markdown
Member Author

This seems fine at a glance, but I’m surprised that it makes the net split detection work by getting scores going more quickly.

I guess the real fix is because this makes sure all the monitors are in the active pinging state before a monitor election finishes, so they default to looking connected instead of unconnected on first check?

Hi @gregsfortytwo,
The problem is that the Monitors can stop pinging each other after election when they haven't established a quorum_mon_feature, this happens when we freshly deploy the cluster or when we restart the monitors.

After going through the Monitor code, I found that mon_feature_t quorum_mon_features is not really persisted, it relies on finishing the election to be assigned. While Elector::begin_peer_ping relies on quorum_mon_features in order to send pings, and it will try to Elector::begin_peer_ping ping during probing which will fail quietly because when the monitor is still probing and it has yet established a quorum_mon_features. After election is finished quorum_mon_features is set and it is assumed that all Monitors in quorum are pinging each other (there's no calling Elector::begin_peer_ping in this election for the Monitors that did not ping each other during the election), which is not true hence the above scenario. It is not obvious because although some Monitors are not pinging each other in this election, the next election will fix this since quorum_mon_features is now established.

The net split detection PR will report a false positive on the election that Elector::begin_peer_ping was not successfully called due to quorum_mon_features not being set.

Therefore, after we established leaders/peon and just before we call Monitor::finish_election(), we try to Elector::begin_peer_ping on the Monitors we missed because quorum_mon_features was not yet set.

@kamoltat

Copy link
Copy Markdown
Member Author

jenkins test make check

@kamoltat

Copy link
Copy Markdown
Member Author

jenkins test make check arm64

@gregsfortytwo

Copy link
Copy Markdown
Member

After election is finished quorum_mon_features is set and it is assumed that all Monitors in quorum are pinging each other (there's no calling Elector::begin_peer_ping in this election for the Monitors that did not ping each other during the election), which is not true hence the above scenario. It is not obvious because although some Monitors are not pinging each other in this election, the next election will fix this since quorum_mon_features is now established.

Oh wow, I would have expected them to start pinging once the election finished. Guess that got missed.

@ljflores

Copy link
Copy Markdown
Member

@gregsfortytwo does this have your approval?

@gregsfortytwo

Copy link
Copy Markdown
Member

@gregsfortytwo does this have your approval?

LGTM

@ljflores

Copy link
Copy Markdown
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants