diff mbox series

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

Message ID 20240315201614.236523-5-i.maximets@ovn.org
State Superseded
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 15, 2024, 8:14 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-vore enabled.  This is causing
an assertion when this server attempts to vote for itself.

Fix that by not using pre-voting if the 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.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 ovsdb/raft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Han Zhou March 26, 2024, 5:45 a.m. UTC | #1
On Fri, Mar 15, 2024 at 1:15 PM Ilya Maximets <i.maximets@ovn.org> wrote:
>
> 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-vore enabled.  This is causing

s/pre-vore/pre-vote

> an assertion when this server attempts to vote for itself.
>
> Fix that by not using pre-voting if the is only one server.

s/the/there

>
> 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.")
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>

Thanks for the fix.
Acked-by: Han Zhou <hzhou@ovn.org>

> ---
>  ovsdb/raft.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ovsdb/raft.c b/ovsdb/raft.c
> index 237d7ebf5..c41419052 100644
> --- a/ovsdb/raft.c
> +++ b/ovsdb/raft.c
> @@ -2083,7 +2083,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);
>          }
>
>      }
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/ovsdb/raft.c b/ovsdb/raft.c
index 237d7ebf5..c41419052 100644
--- a/ovsdb/raft.c
+++ b/ovsdb/raft.c
@@ -2083,7 +2083,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);
         }
 
     }