From ec48c42c981c18cb67e4c2722dfd870d4424ff84 Mon Sep 17 00:00:00 2001 From: Michael Bonfils Date: Fri, 15 Oct 2021 15:37:50 +0000 Subject: [PATCH] Don't try to retrieve term if log is 0 Also use DEBUG instead of ERROR for information log Signed-off-by: Michael Bonfils --- election.c | 2 +- snapshot.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/election.c b/election.c index 663ee99..ef9bff9 100644 --- a/election.c +++ b/election.c @@ -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; diff --git a/snapshot.c b/snapshot.c index 34db6ff..2ca1ab2 100644 --- a/snapshot.c +++ b/snapshot.c @@ -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; -- 2.38.5