box: split promote() into reasonable parts
box_promote() is a monster. It does a lot of different things based on flags: try_wait and run_elections. The flags themselves depend on the node's Raft state and the lunar calendar. Moreover, there are multiple cancellation points and places where external state may have changed and needs a re-check. Things are going to get even worse with the introduction of box.ctl.demote(). So it's time to split up box_promote() into reasonable parts, each doing exactly one thing. This commit mostly addresses the multiple cancellation points issue, so that promote() doesn't look like a huge pile of if(something_changed) blocks. Some other functions will look like that instead. Part of #6034
Loading
Please register or sign in to comment