mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-13 12:58:17 +03:00
F #4809: sync zone update in server add when adding a HA follower in a
federation (for 2 server corner case). Check for empty records in federated log replication
This commit is contained in:
parent
e4e72f5c63
commit
97474282ca
@ -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();
|
||||
}
|
||||
|
||||
|
@ -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<ZonePool *>(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<int> 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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user