mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
F #4809: Fix divergence problems when replicated the fed log in a HA
zone
This commit is contained in:
parent
75dcfd601f
commit
0c9272b69c
@ -102,11 +102,26 @@ int FedReplicaManager::apply_log_record(int index, const std::string& sql)
|
||||
rc = last_index;
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
if ( insert_log_record(last_index + 1, sql) != 0 )
|
||||
std::ostringstream oss;
|
||||
|
||||
char * sql_db = logdb->escape_str(sql.c_str());
|
||||
|
||||
if ( sql_db == 0 )
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return -1;
|
||||
}
|
||||
|
||||
oss << "BEGIN;\n"
|
||||
<< "REPLACE INTO " << table << " ("<< db_names <<") VALUES "
|
||||
<< "(" << last_index + 1 << ",'" << sql_db << "');\n"
|
||||
<< sql << ";\n"
|
||||
<< "END;";
|
||||
|
||||
if ( logdb->exec_wr(oss) != 0 )
|
||||
{
|
||||
pthread_mutex_unlock(&mutex);
|
||||
return -1;
|
||||
@ -114,10 +129,6 @@ int FedReplicaManager::apply_log_record(int index, const std::string& sql)
|
||||
|
||||
last_index++;
|
||||
|
||||
std::ostringstream oss(sql);
|
||||
|
||||
logdb->exec_wr(oss);
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
|
||||
return 0;
|
||||
@ -496,9 +507,12 @@ void FedReplicaManager::replicate_failure(int zone_id, int last_zone)
|
||||
{
|
||||
zs->next = last_zone + 1;
|
||||
}
|
||||
}
|
||||
|
||||
ReplicaManager::replicate(zone_id);
|
||||
if ( last_index >= zs->next )
|
||||
{
|
||||
ReplicaManager::replicate(zone_id);
|
||||
}
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&mutex);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user