raft: fix crash in worker fiber
Raft worker fiber does all the heavy and yielding jobs. These are 2 - disk write, and network broadcast. Disk write yields. Network broadcast is slow, so it happens at most once per event loop iteration. The worker on each iteration check if any of these 2 jobs is active, and if not, it goes to sleep until an explicit wakeup. But there was a bug. Before going to sleep it did a yield + a check that there is nothing to do. However during the yield new tasks could appear, and the check failed, leading to a crash. The patch reorganizes this part of the code so now the worker does not yield between checking new tasks and going to sleep. No test, because extremely hard to reproduce, and don't want to clog this part of the code with error injections.
gerold103/raft-crash in 46 minutes and 43 seconds (queued for 11 minutes and 47 seconds)40 jobs for