[Tarantool-patches] [PATCH v2 13/16] raft: invoke update triggers within state machine
v.shpilevoy at tarantool.org
Fri Nov 20 02:46:01 MSK 2020
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
@@ -574,7 +574,6 @@ raft_worker_handle_broadcast(struct raft *raft)
req.vclock = raft->vclock;
- trigger_run(&raft->on_update, raft);
raft->is_broadcast_scheduled = false;
@@ -967,6 +966,17 @@ raft_new_term(struct raft *raft)
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);
raft->is_broadcast_scheduled = true;
2.24.3 (Apple Git-128)
More information about the Tarantool-patches