1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-03 01:17:41 +03:00

Added debug information to LogDB operations

This commit is contained in:
Ruben S. Montero 2017-07-12 13:02:13 +02:00
parent 5e5cd7f4c8
commit fa9e5d947b
3 changed files with 35 additions and 7 deletions

View File

@ -196,13 +196,16 @@ private:
void finalize_action(const ActionRequest& ar);
/**
* Get the nest record to replicate in a zone
* Get the nerxt record to replicate in a zone
* @param zone_id of the zone
* @param index of the next record to send
* @param sql command to replicate
* @param zedp zone endpoint
* @param lr log record
* @param error description if any
*
* @return 0 on success, -1 otherwise
*/
int get_next_record(int zone_id, std::string& zedp, LogDBRecord& lr);
int get_next_record(int zone_id, std::string& zedp, LogDBRecord& lr,
std::string& error);
};

View File

@ -274,7 +274,7 @@ ReplicaThread * FedReplicaManager::thread_factory(int zone_id)
/* -------------------------------------------------------------------------- */
int FedReplicaManager::get_next_record(int zone_id, std::string& zedp,
LogDBRecord& lr)
LogDBRecord& lr, std::string& error)
{
pthread_mutex_lock(&mutex);
@ -303,6 +303,16 @@ int FedReplicaManager::get_next_record(int zone_id, std::string& zedp,
int rc = logdb->get_log_record(zs->next, lr);
if ( rc == -1 )
{
std::ostringstream oss;
oss << "Failed to load federation log record " << zs->next
<< " for zone " << zs->zone_id;
error = oss.str();
}
pthread_mutex_unlock(&mutex);
return rc;
@ -380,9 +390,8 @@ int FedReplicaManager::xmlrpc_replicate_log(int zone_id, bool& success,
LogDBRecord lr;
if ( get_next_record(zone_id, zedp, lr) != 0 )
if ( get_next_record(zone_id, zedp, lr, error) != 0 )
{
error = "Failed to load federation log record";
return -1;
}

View File

@ -61,6 +61,14 @@ int LogDBRecord::select_cb(void *nil, int num, char **values, char **names)
if ( _sql == 0 )
{
std::ostringstream oss;
oss << "Error zlib inflate for " << index << ", " << fed_index
<< ", " << zsql;
NebulaLog::log("DBM", Log::ERROR, oss);
return -1;
}
@ -191,6 +199,14 @@ int LogDB::get_log_record(unsigned int index, LogDBRecord& lr)
if ( lr.index != index )
{
std::ostringstream oss;
oss << "Log record " << index << " loaded incorrectly. Record index: "
<< lr.index << " fed. index: " << lr.fed_index << " sql command: "
<< lr.sql << ". Operation return code: " << rc;
NebulaLog::log("DBM", Log::ERROR, oss);
rc = -1;
}