[Tarantool-patches] [PATCH v2] raft: make sure the voting mask is wide enough

Cyrill Gorcunov gorcunov at gmail.com
Wed Oct 28 21:56:50 MSK 2020


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 at 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");
 }


More information about the Tarantool-patches mailing list