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