~ne02ptzero/libfloat

ec48c42c981c18cb67e4c2722dfd870d4424ff84 — Michael Bonfils a month ago 0a170e9
Don't try to retrieve term if log is 0

Also use DEBUG instead of ERROR for information log

Signed-off-by: Michael Bonfils <mbonfils@scaleway.com>
2 files changed, 2 insertions(+), 2 deletions(-)

M election.c
M snapshot.c
M election.c => election.c +1 -1
@@ 79,7 79,7 @@ static bool libfloat_can_i_grant_vote(libfloat_ctx_t *ctx, libfloat_rpc_request_
        return false;
    }

    if (libfloat_get_last_term(ctx, NULL, &last_term) == false)
    if (ctx->persistent.commit_index > 0 && libfloat_get_last_term(ctx, NULL, &last_term) == false)
    {
        /* We have failed to retrieve last_ferm from log */
        return false;

M snapshot.c => snapshot.c +1 -1
@@ 189,7 189,7 @@ void libfloat_snapshot_done(libfloat_ctx_t *ctx, bool success)

    /* Write the current snapshot in persistent storage */
    ctx->write_current_snapshot(ctx, ctx->persistent.commit_index, ctx->persistent.term);
    ERROR(ctx, "Writing snapshot with index=%d and term=%d", ctx->persistent.commit_index, ctx->persistent.term);
    DEBUG(ctx, "Writing snapshot with index=%d and term=%d", ctx->persistent.commit_index, ctx->persistent.term);
    ctx->persistent.snapshot.index = ctx->persistent.commit_index;
    ctx->persistent.snapshot.term = ctx->persistent.term;