raft: fix incorrect rpc setup in server_impl::start()
RPC configuration was updated only when an instance was started with an initial snapshot. In case we don't have an initial snapshot, but do have a non-empty log with a configuration entry, the RPC instance isn't set up correctly. Fix that by moving RPC setup code outside the check for snapshot id and look at `_log.get_configuration()` instead. Also, set up RPC mappings both for `current` and `previous` components, since in case the last configuration index points to an entry from the log, it can happen to be a joint configuration entry. For example, this can happen if a leader made an attempt to change configuration, but failed shortly afterwards without being able to commit the new configuration. Tests: unit(dev) Signed-off-by: Pavel Solodovnikov <pa.solodonikov@scylladb.com> Message-Id: <20210423220718.642470-1-pa.solodovnikov@scylladb.com>
This commit is contained in:
committed by
Tomasz Grabiec
parent
f17de6ca45
commit
fba1910770
@@ -234,8 +234,15 @@ future<> server_impl::start() {
|
||||
if (snp_id) {
|
||||
co_await _state_machine->load_snapshot(snp_id);
|
||||
_last_loaded_snapshot_id = snp_id;
|
||||
}
|
||||
|
||||
if (!rpc_config.current.empty()) {
|
||||
// Update RPC address map from the latest configuration (either from
|
||||
// the log or the snapshot)
|
||||
//
|
||||
// Account both for current and previous configurations since
|
||||
// the last configuration idx can point to the joint configuration entry.
|
||||
rpc_config.current.merge(rpc_config.previous);
|
||||
for (const auto& addr: rpc_config.current) {
|
||||
add_to_rpc_config(addr);
|
||||
_rpc->add_server(addr.id, addr.info);
|
||||
|
||||
Reference in New Issue
Block a user