Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko <sergepetrenko@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 13/16] raft: invoke update triggers within state machine
Date: Fri, 20 Nov 2020 12:10:27 +0300	[thread overview]
Message-ID: <5fc200c5-42ed-350f-5a88-58cef911969c@tarantool.org> (raw)
In-Reply-To: <258fb1644bf6c5f9fe187344b98119c40317fc88.1605829282.git.v.shpilevoy@tarantool.org>


20.11.2020 02:46, Vladislav Shpilevoy пишет:
> Raft used to call on_update trigger from the worker fiber. It was
> done because it could yield. But it is not the case anymore. The
> only yielding operation was box_clear_synchro_queue(), which is
> not called from the trigger now.
>
> That makes possible to call the trigger from within of the state
> machine. And this removes the yield between the Raft state change
> and the trigger invocation.
>
> What, in turn, allows to move all box-related urgent updates to
> the trigger. Such as box_update_ro_summary().
>
> Part of #5303


LGTM.

> ---
>   src/box/raftlib.c | 12 +++++++++++-
>   1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/src/box/raftlib.c b/src/box/raftlib.c
> index 4457a784f..f64a66942 100644
> --- a/src/box/raftlib.c
> +++ b/src/box/raftlib.c
> @@ -574,7 +574,6 @@ raft_worker_handle_broadcast(struct raft *raft)
>   		req.vclock = raft->vclock;
>   	}
>   	raft_broadcast(raft, &req);
> -	trigger_run(&raft->on_update, raft);
>   	raft->is_broadcast_scheduled = false;
>   }
>   
> @@ -967,6 +966,17 @@ raft_new_term(struct raft *raft)
>   static void
>   raft_schedule_broadcast(struct raft *raft)
>   {
> +	/*
> +	 * Broadcast works not only for network, but also for other subsystems
> +	 * on the same node. The info is delivered to them via update triggers.
> +	 * But the broadcast happens from inside of the state machine, so it
> +	 * can't yield.
> +	 */
> +	int csw = fiber()->csw;
> +	trigger_run(&raft->on_update, raft);
> +	assert(csw == fiber()->csw);
> +	(void)csw;
> +
>   	raft->is_broadcast_scheduled = true;
>   	raft_schedule_async(raft);
>   }

-- 
Serge Petrenko

  reply	other threads:[~2020-11-20  9:10 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 23:45 [Tarantool-patches] [PATCH v2 00/16] Raft module, part 2 - relocation to src/lib/raft Vladislav Shpilevoy
2020-11-19 23:45 ` [Tarantool-patches] [PATCH v2 01/16] raft: move sources to raftlib.h/.c Vladislav Shpilevoy
2020-11-19 23:45 ` [Tarantool-patches] [PATCH v2 10/16] raft: make worker non-cancellable during WAL write Vladislav Shpilevoy
2020-11-20  8:33   ` Serge Petrenko
2020-11-19 23:45 ` [Tarantool-patches] [PATCH v2 11/16] raft: move worker fiber from Raft library to box Vladislav Shpilevoy
2020-11-20  9:06   ` Serge Petrenko
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 12/16] raft: move synchro queue clear to the worker fiber Vladislav Shpilevoy
2020-11-20  9:07   ` Serge Petrenko
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 13/16] raft: invoke update triggers within state machine Vladislav Shpilevoy
2020-11-20  9:10   ` Serge Petrenko [this message]
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 14/16] raft: move RO summary update to box-Raft Vladislav Shpilevoy
2020-11-20  9:13   ` Serge Petrenko
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 15/16] raft: introduce RaftError Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 16/16] raft: move algorithm code to src/lib/raft Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 02/16] raft: move box_raft_* to src/box/raft.h and .c Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 03/16] raft: stop using replication_disconnect_timeout() Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 04/16] raft: stop using replication_synchro_quorum Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 05/16] raft: stop using instance_id Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 06/16] raft: make raft_request.vclock constant Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 07/16] raft: stop using replicaset.vclock Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 08/16] raft: introduce vtab for disk and network Vladislav Shpilevoy
2020-11-19 23:46 ` [Tarantool-patches] [PATCH v2 09/16] raft: introduce raft_msg, drop xrow dependency Vladislav Shpilevoy
2020-11-20  9:14 ` [Tarantool-patches] [PATCH v2 00/16] Raft module, part 2 - relocation to src/lib/raft Serge Petrenko
2020-11-20 19:42 ` Vladislav Shpilevoy
2020-11-23  5:30 ` Alexander V. Tikhonov
2020-11-23 23:26   ` Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5fc200c5-42ed-350f-5a88-58cef911969c@tarantool.org \
    --to=sergepetrenko@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH v2 13/16] raft: invoke update triggers within state machine' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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