From fa9e5d947b6e2f230506c8992e517b8abb51544a Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Wed, 12 Jul 2017 13:02:13 +0200 Subject: [PATCH] Added debug information to LogDB operations --- include/FedReplicaManager.h | 11 +++++++---- src/raft/FedReplicaManager.cc | 15 ++++++++++++--- src/sql/LogDB.cc | 16 ++++++++++++++++ 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/include/FedReplicaManager.h b/include/FedReplicaManager.h index 59c135b6fb..8ca9a6fe65 100644 --- a/include/FedReplicaManager.h +++ b/include/FedReplicaManager.h @@ -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); }; diff --git a/src/raft/FedReplicaManager.cc b/src/raft/FedReplicaManager.cc index ecb7f7f170..e156375e54 100644 --- a/src/raft/FedReplicaManager.cc +++ b/src/raft/FedReplicaManager.cc @@ -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; } diff --git a/src/sql/LogDB.cc b/src/sql/LogDB.cc index 130463dfbb..b270970aed 100644 --- a/src/sql/LogDB.cc +++ b/src/sql/LogDB.cc @@ -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; }