From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtpng3.m.smailru.net (smtpng3.m.smailru.net [94.100.177.149]) (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 40FDC45C305 for ; Fri, 20 Nov 2020 02:46:18 +0300 (MSK) From: Vladislav Shpilevoy Date: Fri, 20 Nov 2020 00:46:01 +0100 Message-Id: <258fb1644bf6c5f9fe187344b98119c40317fc88.1605829282.git.v.shpilevoy@tarantool.org> In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [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: tarantool-patches@dev.tarantool.org, sergepetrenko@tarantool.org 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 --- 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); } -- 2.24.3 (Apple Git-128)