From: Serge Petrenko <sergepetrenko@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
tarantool-patches@dev.tarantool.org
Subject: Re: [Tarantool-patches] [PATCH v2 12/16] raft: move synchro queue clear to the worker fiber
Date: Fri, 20 Nov 2020 12:07:00 +0300 [thread overview]
Message-ID: <c792e3fb-d15d-adb3-bcb2-4d3935aae84d@tarantool.org> (raw)
In-Reply-To: <9030f25bebf0eee96dbac9b2d80e61716dbf9b87.1605829282.git.v.shpilevoy@tarantool.org>
20.11.2020 02:46, Vladislav Shpilevoy пишет:
> The synchro queue was cleared from the Raft on_update trigger
> installed by box. It was fine as long as the trigger is called
> from the worker fiber, because it won't block the state machine,
> while the synchro queue clearance yields.
>
> But the trigger is going to be called from the Raft state machine
> directly soon. Because it will need to call
> box_update_ro_summary() right after Raft state is updated, without
> a yield to switch to the worker fiber. This will be done in scope
> of getting rid of box in the Raft library.
>
> It means, the trigger can't call box_clear_synchro_queue(). But it
> can schedule its execution for later, since the worker fiber now
> belongs to box. The patch does it.
>
> Part of #5303
Thanks for the patch! LGTM.
> ---
> src/box/raft.c | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
> diff --git a/src/box/raft.c b/src/box/raft.c
> index 0027230da..5ccfb3449 100644
> --- a/src/box/raft.c
> +++ b/src/box/raft.c
> @@ -80,6 +80,19 @@ box_raft_request_to_msg(const struct raft_request *req, struct raft_msg *msg)
> };
> }
>
> +static void
> +box_raft_update_synchro_queue(struct raft *raft)
> +{
> + assert(raft == box_raft());
> + /*
> + * When the node became a leader, it means it will ignore all records
> + * from all the other nodes, and won't get late CONFIRM messages anyway.
> + * Can clear the queue without waiting for confirmations.
> + */
> + if (raft->state == RAFT_STATE_LEADER)
> + box_clear_synchro_queue(false);
> +}
> +
> static int
> box_raft_worker_f(va_list args)
> {
> @@ -90,6 +103,7 @@ box_raft_worker_f(va_list args)
> box_raft_has_work = false;
>
> raft_process_async(raft);
> + box_raft_update_synchro_queue(raft);
>
> if (!box_raft_has_work)
> fiber_yield();
> @@ -142,11 +156,11 @@ box_raft_on_update_f(struct trigger *trigger, void *event)
> if (raft->state != RAFT_STATE_LEADER)
> return 0;
> /*
> - * When the node became a leader, it means it will ignore all records
> - * from all the other nodes, and won't get late CONFIRM messages anyway.
> - * Can clear the queue without waiting for confirmations.
> + * If the node became a leader, time to clear the synchro queue. But it
> + * must be done in the worker fiber so as not to block the state
> + * machine, which called this trigger.
> */
> - box_clear_synchro_queue(false);
> + box_raft_schedule_async(raft);
> return 0;
> }
>
--
Serge Petrenko
next prev parent reply other threads:[~2020-11-20 9:07 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 [this message]
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
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=c792e3fb-d15d-adb3-bcb2-4d3935aae84d@tarantool.org \
--to=sergepetrenko@tarantool.org \
--cc=tarantool-patches@dev.tarantool.org \
--cc=v.shpilevoy@tarantool.org \
--subject='Re: [Tarantool-patches] [PATCH v2 12/16] raft: move synchro queue clear to the worker fiber' \
/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