From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp55.i.mail.ru (smtp55.i.mail.ru [217.69.128.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 04551469710 for ; Fri, 20 Nov 2020 12:10:28 +0300 (MSK) References: <258fb1644bf6c5f9fe187344b98119c40317fc88.1605829282.git.v.shpilevoy@tarantool.org> From: Serge Petrenko Message-ID: <5fc200c5-42ed-350f-5a88-58cef911969c@tarantool.org> Date: Fri, 20 Nov 2020 12:10:27 +0300 MIME-Version: 1.0 In-Reply-To: <258fb1644bf6c5f9fe187344b98119c40317fc88.1605829282.git.v.shpilevoy@tarantool.org> Content-Type: text/plain; charset="utf-8"; format="flowed" Content-Transfer-Encoding: 8bit Content-Language: ru Subject: Re: [Tarantool-patches] [PATCH v2 13/16] raft: invoke update triggers within state machine List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Vladislav Shpilevoy , tarantool-patches@dev.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