~ne02ptzero/libfloat

Check qorum is ok in periodic check v1 APPLIED

Michael Bonfils: 1
 Check qorum is ok in periodic check

 1 files changed, 10 insertions(+), 6 deletions(-)
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~ne02ptzero/libfloat/patches/27509/mbox | git am -3
Learn more about email & git

[PATCH] Check qorum is ok in periodic check Export this patch

Stopped followers didn't trigger a step down from leader
if qorum is no more reached.

Signed-off-by: Michael Bonfils <mbonfils@scaleway.com>
---
 periodic.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/periodic.c b/periodic.c
index 94bf728..f3a95e6 100644
--- a/periodic.c
+++ b/periodic.c
@@ -10,25 +10,29 @@ void libfloat_periodic(libfloat_ctx_t *ctx, uint32_t time)
        {
            if (ctx->conf.sanity_timeout != 0 && ctx->n_nodes > 1)
            {
                bool            node_reachable = false;
                int             nodes_reachables = 0;
                libfloat_node_t *node;

                for_every_node(ctx, node, {
                    if (node->last_update + ctx->conf.sanity_timeout > ctx->time(NULL))
                    if (node->id == ctx->me->id)
                    {
                        node_reachable = true;
                        break;
                        nodes_reachables ++;
                    }
                    else if (node->last_update + ctx->conf.sanity_timeout > ctx->time(NULL))
                    {
                        nodes_reachables ++;
                    }
                });

                if (!node_reachable)
                if (nodes_reachables < ctx->n_nodes / 2 + 1)
                {
                    /**
                    * Hmmm, we might be partitionned, or at the very least we don't have a quorum anymore.
                    * Time to step down!
                    */
                    libfloat_become_follower(ctx);
                    ERROR(ctx, "Sanity timeout has been reached (%d seconds), stepping down from leader position", ctx->conf.sanity_timeout);
                    ERROR(ctx, "Sanity timeout has been reached (%d seconds), stepping down from leader position: reachable %d / quorum %lu (%lu)", 
                          ctx->conf.sanity_timeout, nodes_reachables, ctx->n_nodes / 2 + 1, ctx->n_nodes);
                    return;
                }
            }
-- 
2.25.1
LG