[Tarantool-patches] [PATCH v4 10/16] box: make promote always bump the term
Vladislav Shpilevoy
v.shpilevoy at tarantool.org
Tue Jul 27 02:45:11 MSK 2021
Thanks for the fixes!
> diff --git a/src/box/raft.c b/src/box/raft.c
> index eb62e9630..35c471f58 100644
> --- a/src/box/raft.c
> +++ b/src/box/raft.c
> @@ -394,6 +394,46 @@ box_raft_wait_term_outcome(void)
<...>
> +
> +int
> +box_raft_wait_term_persisted(void)
> +{
> + if (box_raft()->term == box_raft()->volatile_term)
> + return 0;
> + struct raft_wait_persisted_data data = {
> + .waiter = fiber(),
> + .term = box_raft()->volatile_term,
> + };
> + struct trigger trig;
> + trigger_create(&trig, box_raft_wait_term_persisted_f, &data, NULL);
> + raft_on_update(box_raft(), &trig);
> +
> + do {
> + fiber_yield();
> + } while (box_raft()->term < data.term && !fiber_is_cancelled());
Could I ask you please to cache box_raft() into a variable?
It would be shorter and slightly easier to read.
> +
> + trigger_clear(&trig);
> + if (fiber_is_cancelled()) {
> + diag_set(FiberIsCancelled);
> + return -1;
> + }
> + return 0;
> +}
More information about the Tarantool-patches
mailing list