~ne02ptzero/libfloat

log: Bump sanity timeout, add helpers functions for resetting timer routines v1 APPLIED

Louis Solofrizzo: 1
 log: Bump sanity timeout, add helpers functions for resetting timer routines

 3 files changed, 47 insertions(+), 3 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/28821/mbox | git am -3
Learn more about email & git

[PATCH] log: Bump sanity timeout, add helpers functions for resetting timer routines Export this patch

Signed-off-by: Louis Solofrizzo <lsolofrizzo@scaleway.com>
---
 libfloat.c | 23 +++++++++++++++++++++--
 libfloat.h | 25 +++++++++++++++++++++++++
 log.c      |  2 +-
 3 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/libfloat.c b/libfloat.c
index 59c3e8b..62525fb 100644
--- a/libfloat.c
+++ b/libfloat.c
@@ -21,7 +21,7 @@ libfloat_ctx_t *libfloat_ctx_new(void *(*malloc)(size_t), void *(*calloc)(size_t
    ret->conf.log_commit_timeout = 5;
    ret->conf.compact_every_n_log = 10000;
    ret->conf.avoid_congestion = false;
    ret->conf.sanity_timeout = 6;
    ret->conf.sanity_timeout = 10;
    ret->conf.optimistic_replication = true;
    ret->conf.max_logs_per_ae = 500;
    ret->conf.do_revert = false;
@@ -114,4 +114,23 @@ libfloat_entry_id_t libfloat_node_get_next_log(libfloat_node_t *node)
libfloat_entry_id_t libfloat_node_get_replicated_log(libfloat_node_t *node)
{
    return node->replicated_log;
}
\ No newline at end of file
}

void libfloat_reset_timeout_elapsed(libfloat_ctx_t *ctx)
{
    if (!libfloat_am_i_leader(ctx))
    {
        ctx->timeout_elapsed = 0;
    }
}

void libfloat_update_last_update(libfloat_ctx_t *ctx, libfloat_node_id_t id)
{
    if (libfloat_am_i_leader(ctx))
    {
        libfloat_node_t         *node = libfloat_get_node(ctx, id);

        if (node != NULL)
            node->last_update = ctx->time(NULL);
    }
}
diff --git a/libfloat.h b/libfloat.h
index 69f040f..0e724fa 100644
--- a/libfloat.h
+++ b/libfloat.h
@@ -540,4 +540,29 @@ libfloat_entry_id_t libfloat_node_get_next_log(libfloat_node_t *node);
 */
libfloat_entry_id_t libfloat_node_get_replicated_log(libfloat_node_t *node);

/*!
 * \brief Reset timeout elasped on followers, in order not to trigger an election
 *
 * \param[in] ctx Libfloat context
 *
 * \note Follower function only
 * \note This function is intended to be called when network happens outside of
 * libfloat (like snapshotting), and the timer needs to be reseted in order not
 * to trigger an election.
 */
void libfloat_reset_timeout_elapsed(libfloat_ctx_t *ctx);

/*!
 * \brief Update the last hearbeat we received from a node
 *
 * \param[in] ctx Libfloat context
 * \param[in] id Node ID to update
 *
 * \note Leader function only
 * \note This function is intended to be valled when network happens outside of
 * libfloat (like snapshotting), and the node timers needs to be reseted not to
 * trigger the sanity timeout
 */
void libfloat_update_last_update(libfloat_ctx_t *ctx, libfloat_node_id_t id);

#endif /* LIBFLOAT_H */
diff --git a/log.c b/log.c
index b761c57..58610a0 100644
--- a/log.c
+++ b/log.c
@@ -668,7 +668,7 @@ void libfloat_append_entries_response(libfloat_ctx_t *ctx, libfloat_rpc_append_e
                node->id, resp->current_index, node->replicated_log);
        }

        node->next_log_to_send = max(resp->current_index, 1);
        node->next_log_to_send = max(resp->current_index + 1, 1);
        node->replicated_log = resp->current_index;

        libfloat_send_append_entries(ctx, node, false);
-- 
2.35.0
LG

--
Michael Bonfils
htps://www.murlock.org/

‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐