replication: make replica subscribe to master's ballot
Previously replicas chose the remote master to boot from by comparing master ballot, which are received in response to IPROTO_VOTE request right on connection init. Such information is not enough in some scenarios. For example, when implementing anonymous replicas and retrying relica join, we had to restart all connections in order to get the latest ballot information. Let's change that: make replica subscribe to the built-in "internal.ballot" event instead of relying on request-response scheme of IPROTO_VOTE. Now replicas always have up-to-date ballot information and there is no need to reinitialize connections to update the ballots. Introduce a new fiber running in tx thread for this purpose: applier ballot watcher. The fiber subscribes on "internal.ballot" event and watches it all the time while the connection to master is alive. In case the master isn't aware of IPROTO_WATCH request or of "internal.ballot" event, old behaviour is also implemented: ballot watcher simply waits for IPROTO_VOTE response and exits. The ballot watcher is started whenever replica tries to connect or reconnect to the remote master and is cancelled whenever its parent connection to the master is closed. We do not put much effort into restarting the fiber and retrying to connect in case it fails. For now ballot info is only used during bootstrap, and not trying to keep the fiber alive at all costs simplifies the code quite a lot. Later on ballot subscriptions will play a more significant role in choosing the bootstrap leader: replicas will re-check remote ballots every now and then during the bootstrap leader election. Part-of #5272 NO_CHANGELOG=internal change NO_TEST=tested by existing replication tests NO_DOC=internal change
Showing
- src/box/applier.cc 222 additions, 20 deletionssrc/box/applier.cc
- src/box/applier.h 6 additions, 0 deletionssrc/box/applier.h
- src/box/errcode.h 1 addition, 0 deletionssrc/box/errcode.h
- src/box/xrow.c 36 additions, 0 deletionssrc/box/xrow.c
- src/box/xrow.h 37 additions, 0 deletionssrc/box/xrow.h
- test/box/error.result 1 addition, 0 deletionstest/box/error.result
Loading
Please register or sign in to comment