From 510c7f767f79241667d82cbb7c077c8cf327c0c7 Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Tue, 12 Feb 2019 15:56:22 +0200 Subject: [PATCH] Deal with backwards compatibility in sst_received() Earlier versions of cluster software may not support storing the view info into stable storage. In order to work around this during rolling upgrade, skip sanity checks for recovered view if the view state_id ID is undefined. --- src/server_state.cpp | 50 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/server_state.cpp b/src/server_state.cpp index f51285b..af0b313 100644 --- a/src/server_state.cpp +++ b/src/server_state.cpp @@ -563,24 +563,42 @@ void wsrep::server_state::sst_received(wsrep::client_service& cs, wsrep::view const v(server_service_.get_view(cs, id_)); wsrep::log_info() << "Recovered view from SST:\n" << v; - if (v.state_id().id() != gtid.id() || - v.state_id().seqno() > gtid.seqno()) + /* + * If the state id from recovered view has undefined ID, we may + * be upgrading from earlier version which does not provide + * view stored in stable storage. In this case we skip + * sanity checks and assigning the current view and wait + * until the first view delivery. + */ + if (v.state_id().id().is_undefined() == false) { - /* Since IN GENERAL we may not be able to recover SST GTID from - * the state data, we have to rely on SST script passing the GTID - * value explicitly. - * Here we check if the passed GTID makes any sense: it should - * have the same UUID and greater or equal seqno than the last - * logged view. */ - std::ostringstream msg; - msg << "SST script passed bogus GTID: " << gtid - << ". Preceeding view GTID: " << v.state_id(); - throw wsrep::runtime_error(msg.str()); + if (v.state_id().id() != gtid.id() || + v.state_id().seqno() > gtid.seqno()) + { + /* Since IN GENERAL we may not be able to recover SST GTID from + * the state data, we have to rely on SST script passing the + * GTID value explicitly. + * Here we check if the passed GTID makes any sense: it should + * have the same UUID and greater or equal seqno than the last + * logged view. */ + std::ostringstream msg; + msg << "SST script passed bogus GTID: " << gtid + << ". Preceeding view GTID: " << v.state_id(); + throw wsrep::runtime_error(msg.str()); + } + + current_view_ = v; + server_service_.log_view(NULL /* this view is stored already */, v); + } + else + { + wsrep::log_warning() + << "View recovered from stable storage was empty. If the " + << "server is doing rolling upgrade from previous version " + << "which does not support storing view info into stable " + << "storage, this is ok. Otherwise this may be a sign of " + << "malfunction."; } - - current_view_ = v; - server_service_.log_view(NULL /* this view is stored already */, v); - lock.lock(); recover_streaming_appliers_if_not_recovered(lock, cs); lock.unlock();