diff --git a/src/nebula/Nebula.cc b/src/nebula/Nebula.cc index f97b57ede2..0e69fbe131 100644 --- a/src/nebula/Nebula.cc +++ b/src/nebula/Nebula.cc @@ -755,7 +755,7 @@ void Nebula::start(bool bootstrap_only) if ( is_federation_master() && solo ) { // Replica threads are started on master in solo mode. - // HA start/stop the replica threads on leader/follower states will + // HA start/stop the replica threads on leader/follower states frm->start_replica_threads(); } diff --git a/src/rm/RequestManagerZone.cc b/src/rm/RequestManagerZone.cc index 7c99ddc1fc..875958e233 100644 --- a/src/rm/RequestManagerZone.cc +++ b/src/rm/RequestManagerZone.cc @@ -131,6 +131,8 @@ void ZoneAddServer::request_execute(xmlrpc_c::paramList const& paramList, int oid = zone->get_oid(); + unsigned int numservers = zone->servers_size(); + zone->to_xml(tmpl_xml); ErrorCode ec = master_update_zone(oid, tmpl_xml, att); @@ -144,6 +146,28 @@ void ZoneAddServer::request_execute(xmlrpc_c::paramList const& paramList, failure_response(ec, att); return; } + + //Wait for zone update to propagate from master before adding the + //new server + if ( numservers == 2 ) + { + bool updated = false; + + while (!updated) + { + Zone * zone = (static_cast(pool))->get(id, true); + + if ( zone != 0 ) + { + if ( zone->get_server(zs_id) != 0 ) + { + updated = true; + } + } + + usleep(250000); + } + } } nd.get_raftm()->add_server(zs_id, xmlep); @@ -196,6 +220,8 @@ void ZoneDeleteServer::request_execute(xmlrpc_c::paramList const& paramList, return; } + nd.get_raftm()->delete_server(zs_id); + if ( nd.is_federation_master() || !nd.is_federation_enabled() ) { std::vector zids; @@ -227,8 +253,6 @@ void ZoneDeleteServer::request_execute(xmlrpc_c::paramList const& paramList, } } - nd.get_raftm()->delete_server(zs_id); - success_response(id, att); } @@ -501,6 +525,19 @@ void ZoneReplicateFedLog::request_execute(xmlrpc_c::paramList const& paramList, return; } + if ( sql.empty() ) + { + oss << "Received an empty SQL command at index" << index; + + NebulaLog::log("ReM", Log::ERROR, oss); + + att.resp_msg = oss.str(); + att.resp_id = index; + + failure_response(ACTION, att); + return; + } + if ( !nd.is_federation_slave() ) { oss << "Cannot replicate federate log records on federation master"; @@ -511,6 +548,7 @@ void ZoneReplicateFedLog::request_execute(xmlrpc_c::paramList const& paramList, att.resp_id = - 1; failure_response(ACTION, att); + return; } int rc = frm->apply_log_record(index, sql); @@ -526,7 +564,7 @@ void ZoneReplicateFedLog::request_execute(xmlrpc_c::paramList const& paramList, NebulaLog::log("ReM", Log::INFO, oss); att.resp_msg = oss.str(); - att.resp_id = index - 1; + att.resp_id = index; failure_response(ACTION, att); } @@ -544,3 +582,4 @@ void ZoneReplicateFedLog::request_execute(xmlrpc_c::paramList const& paramList, return; } +