From fba19107701d7f513d980750a69e32d83ea09ceb Mon Sep 17 00:00:00 2001 From: Pavel Solodovnikov Date: Sat, 24 Apr 2021 01:07:18 +0300 Subject: [PATCH] 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 Message-Id: <20210423220718.642470-1-pa.solodovnikov@scylladb.com> --- raft/server.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/raft/server.cc b/raft/server.cc index 9881347a28..482f21b78e 100644 --- a/raft/server.cc +++ b/raft/server.cc @@ -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);