~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
2 2

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

Louis Solofrizzo <lsolofrizzo@scaleway.com>
Details
Message ID
<20220128172512.2855831-1-lsolofrizzo@scaleway.com>
DKIM signature
pass
Download raw message
Patch: +47 -3
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
Details
Message ID
<20220128173818.cfxdtiwu2tq24n7l@scaleway>
In-Reply-To
<20220128172512.2855831-1-lsolofrizzo@scaleway.com> (view parent)
DKIM signature
pass
Download raw message
On 22/01/28 06:25PM, Louis Solofrizzo wrote:
> +/*!
> + * \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
called

LG
Details
Message ID
<osu0uZt9aCbr6bjCZjnyvWwaDb1JqMHsG0ZCp85yCMN8c2CRM_U4Q1rLeIyopEghBkDR2N0hxdXcVQbn_FkIbaRfXTRkRojSVFCJot3s9H8=@protonmail.com>
In-Reply-To
<20220128172512.2855831-1-lsolofrizzo@scaleway.com> (view parent)
DKIM signature
pass
Download raw message
LG

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

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

On Friday, January 28th, 2022 at 6:25 PM, Louis Solofrizzo <lsolofrizzo@scaleway.com> wrote:

> 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
Reply to thread Export thread (mbox)