Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] raft: make sure the voking mask is wide enough
@ 2020-10-28 18:13 Cyrill Gorcunov
  2020-10-28 18:56 ` [Tarantool-patches] [PATCH v2] raft: make sure the voting " Cyrill Gorcunov
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Cyrill Gorcunov @ 2020-10-28 18:13 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

The vote_mask is declared as uint32_t which is highly coupled
with VCLOCK_MAX, lets add a compile time test to be sure.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
I didn't make any branch here since it is trivial, fetch
it from the mbox please if decide to apply.

 src/box/raft.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: tarantool.git/src/box/raft.c
===================================================================
--- tarantool.git.orig/src/box/raft.c
+++ tarantool.git/src/box/raft.c
@@ -1061,4 +1061,10 @@ raft_init(void)
 {
 	ev_timer_init(&raft.timer, raft_sm_schedule_new_election_cb, 0, 0);
 	rlist_create(&raft.on_update);
+
+	/*
+	 * Make sure there is enough bits to track all replicas.
+	 */
+	static_assert(sizeof(raft.vote_mask) * 8 >= VCLOCK_MAX,
+		      "RAFT: vote_mask is too short");
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Tarantool-patches] [PATCH v2] raft: make sure the voting mask is wide enough
  2020-10-28 18:13 [Tarantool-patches] raft: make sure the voking mask is wide enough Cyrill Gorcunov
@ 2020-10-28 18:56 ` Cyrill Gorcunov
  2020-10-30  7:33   ` Serge Petrenko
  2020-11-02 22:04 ` [Tarantool-patches] " Vladislav Shpilevoy
  2020-11-02 22:28 ` Vladislav Shpilevoy
  2 siblings, 1 reply; 8+ messages in thread
From: Cyrill Gorcunov @ 2020-10-28 18:56 UTC (permalink / raw)
  To: tml; +Cc: Vladislav Shpilevoy

The vote_mask is declared as uint32_t which is highly coupled
with VCLOCK_MAX, lets add a compile time test to be sure.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
I didn't make any branch here since it is trivial, fetch
it from the mbox please if decide to apply. In v2 I fixed
a few grammar typos.

 src/box/raft.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: tarantool.git/src/box/raft.c
===================================================================
--- tarantool.git.orig/src/box/raft.c
+++ tarantool.git/src/box/raft.c
@@ -1061,4 +1061,10 @@ raft_init(void)
 {
 	ev_timer_init(&raft.timer, raft_sm_schedule_new_election_cb, 0, 0);
 	rlist_create(&raft.on_update);
+
+	/*
+	 * Make sure there are enough bits to track all replicas.
+	 */
+	static_assert(sizeof(raft.vote_mask) * 8 >= VCLOCK_MAX,
+		      "RAFT: vote_mask is too short");
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH v2] raft: make sure the voting mask is wide enough
  2020-10-28 18:56 ` [Tarantool-patches] [PATCH v2] raft: make sure the voting " Cyrill Gorcunov
@ 2020-10-30  7:33   ` Serge Petrenko
  2020-10-30  8:30     ` [Tarantool-patches] [PATCH v3] raft: make sure the voking " Cyrill Gorcunov
  0 siblings, 1 reply; 8+ messages in thread
From: Serge Petrenko @ 2020-10-30  7:33 UTC (permalink / raw)
  To: Cyrill Gorcunov, tml; +Cc: Vladislav Shpilevoy

28.10.2020 21:56, Cyrill Gorcunov пишет:

> The vote_mask is declared as uint32_t which is highly coupled
> with VCLOCK_MAX, lets add a compile time test to be sure.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> I didn't make any branch here since it is trivial, fetch
> it from the mbox please if decide to apply. In v2 I fixed
> a few grammar typos.
Hi! Please see one comment below.
>
>   src/box/raft.c |    6 ++++++
>   1 file changed, 6 insertions(+)
>
> Index: tarantool.git/src/box/raft.c
> ===================================================================
> --- tarantool.git.orig/src/box/raft.c
> +++ tarantool.git/src/box/raft.c
> @@ -1061,4 +1061,10 @@ raft_init(void)
>   {
>   	ev_timer_init(&raft.timer, raft_sm_schedule_new_election_cb, 0, 0);
>   	rlist_create(&raft.on_update);
> +
> +	/*
> +	 * Make sure there are enough bits to track all replicas.
> +	 */
> +	static_assert(sizeof(raft.vote_mask) * 8 >= VCLOCK_MAX,

CHAR_BIT is used instead of `8` everywhere in the code (well, almost 
everywhere).

So please conform.

> +		      "RAFT: vote_mask is too short");

-- 
Serge Petrenko

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Tarantool-patches] [PATCH v3] raft: make sure the voking mask is wide enough
  2020-10-30  7:33   ` Serge Petrenko
@ 2020-10-30  8:30     ` Cyrill Gorcunov
  2020-10-30  8:39       ` Serge Petrenko
  0 siblings, 1 reply; 8+ messages in thread
From: Cyrill Gorcunov @ 2020-10-30  8:30 UTC (permalink / raw)
  To: Serge Petrenko; +Cc: tml, Vladislav Shpilevoy

The vote_mask is declared as uint32_t which is highly coupled
with VCLOCK_MAX, lets add a compile time test to be sure.

Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
---
v2:
 Use CHAR_BIT instead of hardcoded bits number

 src/box/raft.c |    6 ++++++
 1 file changed, 6 insertions(+)

Index: tarantool.git/src/box/raft.c
===================================================================
--- tarantool.git.orig/src/box/raft.c
+++ tarantool.git/src/box/raft.c
@@ -1061,4 +1061,10 @@ raft_init(void)
 {
 	ev_timer_init(&raft.timer, raft_sm_schedule_new_election_cb, 0, 0);
 	rlist_create(&raft.on_update);
+
+	/*
+	 * Make sure there is enough bits to track all replicas.
+	 */
+	static_assert(sizeof(raft.vote_mask) * CHAR_BIT >= VCLOCK_MAX,
+		      "RAFT: vote_mask is too short");
 }

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] [PATCH v3] raft: make sure the voking mask is wide enough
  2020-10-30  8:30     ` [Tarantool-patches] [PATCH v3] raft: make sure the voking " Cyrill Gorcunov
@ 2020-10-30  8:39       ` Serge Petrenko
  0 siblings, 0 replies; 8+ messages in thread
From: Serge Petrenko @ 2020-10-30  8:39 UTC (permalink / raw)
  To: Cyrill Gorcunov; +Cc: tml, Vladislav Shpilevoy


30.10.2020 11:30, Cyrill Gorcunov пишет:
> The vote_mask is declared as uint32_t which is highly coupled
> with VCLOCK_MAX, lets add a compile time test to be sure.
>
> Signed-off-by: Cyrill Gorcunov <gorcunov@gmail.com>
> ---
> v2:
>   Use CHAR_BIT instead of hardcoded bits number
>
>   src/box/raft.c |    6 ++++++
>   1 file changed, 6 insertions(+)
>
> Index: tarantool.git/src/box/raft.c
> ===================================================================
> --- tarantool.git.orig/src/box/raft.c
> +++ tarantool.git/src/box/raft.c
> @@ -1061,4 +1061,10 @@ raft_init(void)
>   {
>   	ev_timer_init(&raft.timer, raft_sm_schedule_new_election_cb, 0, 0);
>   	rlist_create(&raft.on_update);
> +
> +	/*
> +	 * Make sure there is enough bits to track all replicas.
> +	 */
> +	static_assert(sizeof(raft.vote_mask) * CHAR_BIT >= VCLOCK_MAX,
> +		      "RAFT: vote_mask is too short");
>   }
Thanks for the fix! LGTM.

-- 
Serge Petrenko

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] raft: make sure the voking mask is wide enough
  2020-10-28 18:13 [Tarantool-patches] raft: make sure the voking mask is wide enough Cyrill Gorcunov
  2020-10-28 18:56 ` [Tarantool-patches] [PATCH v2] raft: make sure the voting " Cyrill Gorcunov
@ 2020-11-02 22:04 ` Vladislav Shpilevoy
  2020-11-02 22:17   ` Cyrill Gorcunov
  2020-11-02 22:28 ` Vladislav Shpilevoy
  2 siblings, 1 reply; 8+ messages in thread
From: Vladislav Shpilevoy @ 2020-11-02 22:04 UTC (permalink / raw)
  To: Cyrill Gorcunov, tml

Hi! I don't see a branch name, and can't find it in the branches
on github.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] raft: make sure the voking mask is wide enough
  2020-11-02 22:04 ` [Tarantool-patches] " Vladislav Shpilevoy
@ 2020-11-02 22:17   ` Cyrill Gorcunov
  0 siblings, 0 replies; 8+ messages in thread
From: Cyrill Gorcunov @ 2020-11-02 22:17 UTC (permalink / raw)
  To: Vladislav Shpilevoy; +Cc: tml

On Mon, Nov 02, 2020 at 11:04:44PM +0100, Vladislav Shpilevoy wrote:
> Hi! I don't see a branch name, and can't find it in the branches
> on github.

I didn't push it initially, thought you could fetch it from mbox
since it trivial oneliner. Anyway pushed into gorcunov/raft-vote-mask

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [Tarantool-patches] raft: make sure the voking mask is wide enough
  2020-10-28 18:13 [Tarantool-patches] raft: make sure the voking mask is wide enough Cyrill Gorcunov
  2020-10-28 18:56 ` [Tarantool-patches] [PATCH v2] raft: make sure the voting " Cyrill Gorcunov
  2020-11-02 22:04 ` [Tarantool-patches] " Vladislav Shpilevoy
@ 2020-11-02 22:28 ` Vladislav Shpilevoy
  2 siblings, 0 replies; 8+ messages in thread
From: Vladislav Shpilevoy @ 2020-11-02 22:28 UTC (permalink / raw)
  To: Cyrill Gorcunov, tml

Thanks for the patch!

It would be better to replace uint32_t with vclock_map_t
for vote_mask member. I didn't think of that type when implemented
the mask, but it seems to fit here better than a static assertion
and uint32_t.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-11-02 22:28 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-28 18:13 [Tarantool-patches] raft: make sure the voking mask is wide enough Cyrill Gorcunov
2020-10-28 18:56 ` [Tarantool-patches] [PATCH v2] raft: make sure the voting " Cyrill Gorcunov
2020-10-30  7:33   ` Serge Petrenko
2020-10-30  8:30     ` [Tarantool-patches] [PATCH v3] raft: make sure the voking " Cyrill Gorcunov
2020-10-30  8:39       ` Serge Petrenko
2020-11-02 22:04 ` [Tarantool-patches] " Vladislav Shpilevoy
2020-11-02 22:17   ` Cyrill Gorcunov
2020-11-02 22:28 ` Vladislav Shpilevoy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox