diff mbox series

[ovs-dev,v2,4/5] ovsdb: raft: Fix assertion when 1-node cluster looses leadership.

Message ID 20240326172717.1454071-5-i.maximets@ovn.org
State Accepted
Commit e987af503975d6d1600e59f7da1bb465eb66aca3
Headers show
Series ovsdb: raft: Fixes for cluster joining state. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Ilya Maximets March 26, 2024, 5:27 p.m. UTC
Some of the failure tests can make a single-node cluster to
loose leadership.  In this case the next raft_run() will
trigger election with a pre-vote enabled.  This is causing
an assertion when this server attempts to vote for itself.

Fix that by not using pre-voting if there is only one server.

A new failure test introduced in later commit triggers this
assertion every time.

Fixes: 85634fd58004 ("ovsdb: raft: Support pre-vote mechanism to deal with disruptive server.")
Acked-by: Han Zhou <hzhou@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 ovsdb/raft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/ovsdb/raft.c b/ovsdb/raft.c
index 5d7e88732..0c171b754 100644
--- a/ovsdb/raft.c
+++ b/ovsdb/raft.c
@@ -2120,7 +2120,7 @@  raft_run(struct raft *raft)
                 raft_start_election(raft, true, false);
             }
         } else {
-            raft_start_election(raft, true, false);
+            raft_start_election(raft, hmap_count(&raft->servers) > 1, false);
         }
 
     }