~ne02ptzero/libfloat

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] periodic: Trigger an election when a leader has lost its followers

Louis Solofrizzo <lsolofrizzo@scaleway.com>
Details
Message ID
<20230721133738.2982965-1-lsolofrizzo@scaleway.com>
DKIM signature
missing
Download raw message
Patch: +10 -10
Also fixes some formatting issues in the latest patch.

Signed-off-by: Louis Solofrizzo <lsolofrizzo@scaleway.com>
---
 periodic.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/periodic.c b/periodic.c
index 556bfec..53fcd71 100644
--- a/periodic.c
+++ b/periodic.c
@@ -57,7 +57,7 @@ void libfloat_periodic(libfloat_ctx_t *ctx, uint32_t time)
                    * 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, .reason = "not enough nodes reachable");
                    libfloat_election_start(ctx, .reason = "We have not heard from our nodes, possible split?", .force = true);
                    ERROR(ctx, "Sanity timeout has been reached (%ld seconds), stepping down from leader position: reachable %lu / quorum %lu (%lu)",
                          ctx->conf.sanity_timeout, nodes_reachable, ctx->n_nodes / 2 + 1, ctx->n_nodes);
                    return;
@@ -114,17 +114,17 @@ void libfloat_periodic(libfloat_ctx_t *ctx, uint32_t time)
        {
            if (ctx->soft_compact_last_log != ctx->persistent.commit_index)
            {
                /* If soft compact is enabled, let's check if the timing is right */                                         
                /* If soft compact is enabled, let's check if the timing is right */
                if (ctx->last_log_time + ctx->conf.soft_compact_time < ms_to_s(ctx->global_timer))
                {                                                                                                               
                    ctx->soft_compact_last_log = ctx->persistent.commit_index;                                                  
                    if (ctx->persistent.commit_index - ctx->persistent.snapshot.index >= ctx->conf.soft_compact_every_n_log)    
                    {                                                                                                           
                        ctx->append_snapshot_log(ctx, ctx->persistent.commit_index, ctx->persistent.term);                      
                {
                    ctx->soft_compact_last_log = ctx->persistent.commit_index;
                    if (ctx->persistent.commit_index - ctx->persistent.snapshot.index >= ctx->conf.soft_compact_every_n_log)
                    {
                        ctx->append_snapshot_log(ctx, ctx->persistent.commit_index, ctx->persistent.term);
                        ctx->soft_compact_last_log++;
                    }                                                                                                           
                }                                                                                                               
            } 
                    }
                }
            }
        }
    }
    else if (ctx->election_timeout_rand <= ctx->timeout_elapsed)
-- 
2.41.0
Details
Message ID
<1660db92-5449-48c6-91e4-ae6ad15da18d@ptrk.io>
In-Reply-To
<20230721133738.2982965-1-lsolofrizzo@scaleway.com> (view parent)
DKIM signature
missing
Download raw message
LG
Reply to thread Export thread (mbox)