1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

F #4809: Do not accept empty records. Increase default xml-rpc timeouts

This commit is contained in:
Ruben S. Montero 2017-05-24 20:38:13 +02:00
parent a216bb9eb4
commit 98d26e9e4c
4 changed files with 38 additions and 15 deletions

View File

@ -89,7 +89,7 @@ public:
* @param endpoint of server
* @param method name
* @param plist initialized param list
* @param timeout for the request, set 0 for global xml_rpc timeout
* @param timeout (ms) for the request, set 0 for global xml_rpc timeout
* @param result of the xmlrpc call
* @param error string if any
* @return 0

View File

@ -196,8 +196,8 @@ protected:
leader_only = true;
//TODO Get this from oned.conf
xmlrpc_timeout = 500;
//TODO Get this from oned.conf (10s)
xmlrpc_timeout = 10000;
};
virtual ~Request(){};

View File

@ -29,7 +29,7 @@ const char * FedReplicaManager::db_names = "log_index, sql";
const char * FedReplicaManager::db_bootstrap = "CREATE TABLE IF NOT EXISTS "
"fed_logdb (log_index INTEGER PRIMARY KEY, sql MEDIUMTEXT)";
const time_t FedReplicaManager::xmlrpc_timeout_ms = 2000;
const time_t FedReplicaManager::xmlrpc_timeout_ms = 10000;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@ -292,20 +292,26 @@ void FedReplicaManager::timer_action(const ActionRequest& ar)
// Database housekeeping
if ( (purge_tics * timer_period) >= purge_period )
{
NebulaLog::log("FRM", Log::INFO, "Purging federated log");
Nebula& nd = Nebula::instance();
RaftManager * raftm = nd.get_raftm();
std::ostringstream oss;
if ( raftm->is_leader() || raftm->is_solo() )
{
NebulaLog::log("FRM", Log::INFO, "Purging federated log");
pthread_mutex_lock(&mutex);
std::ostringstream oss;
// keep the last "log_retention" records
oss << "DELETE FROM fed_logdb WHERE log_index NOT IN (SELECT "
<< "log_index FROM fed_logdb ORDER BY log_index DESC LIMIT "
<< log_retention <<")";
pthread_mutex_lock(&mutex);
logdb->exec_wr(oss);
// keep the last "log_retention" records
oss << "DELETE FROM fed_logdb WHERE log_index NOT IN (SELECT "
<< "log_index FROM fed_logdb ORDER BY log_index DESC LIMIT "
<< log_retention <<")";
pthread_mutex_unlock(&mutex);
logdb->exec_wr(oss);
pthread_mutex_unlock(&mutex);
}
purge_tics = 0;
}

View File

@ -300,7 +300,9 @@ void ZoneReplicateLog::request_execute(xmlrpc_c::paramList const& paramList,
raftm->update_last_heartbeat(leader_id);
//HEARTBEAT
//--------------------------------------------------------------------------
// HEARTBEAT
//--------------------------------------------------------------------------
if ( index == 0 && prev_index == 0 && term == 0 && prev_term == 0 &&
sql.empty() )
{
@ -316,7 +318,22 @@ void ZoneReplicateLog::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
//REPLICATE
//--------------------------------------------------------------------------
// REPLICATE
// 0. Check it is a valid record (prevent spurious entries)
// 1. Check log consistency (index, and previous index match)
// 2. Insert record in the log
// 3. Apply log records that can be safely applied
//--------------------------------------------------------------------------
if ( sql.empty() )
{
att.resp_msg = "Empty SQL command in log record";
att.resp_id = current_term;
failure_response(ACTION, att);
return;
}
if ( index > 0 )
{
if ( logdb->get_log_record(prev_index, prev_lr) != 0 )