From df7fbf2669ed6fe7dd6131c59b35eead6cfc31b9 Mon Sep 17 00:00:00 2001 From: Shu0T1an ChenG Date: Sun, 10 Sep 2017 23:44:08 -0700 Subject: [PATCH] [buffer]: Remove failed tasks from the m_toSync queue - Remove the task with erase(it) to avoid looping inside the while - Align the code and refactor the error messages - Remove table verification code since it is unnecessary --- orchagent/bufferorch.cpp | 50 ++++++++++++++++++---------------------- orchagent/qosorch.cpp | 4 ++-- 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/orchagent/bufferorch.cpp b/orchagent/bufferorch.cpp index 503407db2a..72f17dd5ff 100644 --- a/orchagent/bufferorch.cpp +++ b/orchagent/bufferorch.cpp @@ -526,41 +526,37 @@ void BufferOrch::doTask(Consumer &consumer) auto it = consumer.m_toSync.begin(); while (it != consumer.m_toSync.end()) { - KeyOpFieldsValuesTuple tuple = it->second; - string map_type_name = consumer.m_consumer->getTableName(); - if (m_buffer_type_maps.find(map_type_name) == m_buffer_type_maps.end()) - { - SWSS_LOG_ERROR("Unrecognised qos table encountered:%s", map_type_name.c_str()); - it = consumer.m_toSync.erase(it); - continue; - } + /* Make sure the handler is initialized for the task */ + auto map_type_name = consumer.m_consumer->getTableName(); if (m_bufferHandlerMap.find(map_type_name) == m_bufferHandlerMap.end()) { SWSS_LOG_ERROR("No handler for key:%s found.", map_type_name.c_str()); it = consumer.m_toSync.erase(it); continue; } - task_process_status task_status = (this->*(m_bufferHandlerMap[map_type_name]))(consumer); + + auto task_status = (this->*(m_bufferHandlerMap[map_type_name]))(consumer); switch(task_status) { - case task_process_status::task_success : - it = consumer.m_toSync.erase(it); - break; - case task_process_status::task_invalid_entry: - SWSS_LOG_ERROR("Invalid buffer task item was encountered, removing from queue."); - it = consumer.m_toSync.erase(it); - break; - case task_process_status::task_failed: - SWSS_LOG_ERROR("Processing buffer task item failed, exiting."); - return; - case task_process_status::task_need_retry: - SWSS_LOG_INFO("Processing buffer task item failed, will retry."); - it++; - break; - default: - SWSS_LOG_ERROR("Unknown task status: %d", task_status); - it = consumer.m_toSync.erase(it); - break; + case task_process_status::task_success : + it = consumer.m_toSync.erase(it); + break; + case task_process_status::task_invalid_entry: + SWSS_LOG_ERROR("Failed to process invalid buffer task"); + it = consumer.m_toSync.erase(it); + break; + case task_process_status::task_failed: + SWSS_LOG_ERROR("Failed to process buffer task, drop it"); + it = consumer.m_toSync.erase(it); + return; + case task_process_status::task_need_retry: + SWSS_LOG_INFO("Failed to process buffer task, retry it"); + it++; + break; + default: + SWSS_LOG_ERROR("Invalid task status %d", task_status); + it = consumer.m_toSync.erase(it); + break; } } } diff --git a/orchagent/qosorch.cpp b/orchagent/qosorch.cpp index 943da55dd8..37dbad2390 100644 --- a/orchagent/qosorch.cpp +++ b/orchagent/qosorch.cpp @@ -1243,7 +1243,7 @@ void QosOrch::doTask(Consumer &consumer) while (it != consumer.m_toSync.end()) { /* Make sure the handler is initialized for the task */ - string qos_map_type_name = consumer.m_consumer->getTableName(); + auto qos_map_type_name = consumer.m_consumer->getTableName(); if (m_qos_handler_map.find(qos_map_type_name) == m_qos_handler_map.end()) { SWSS_LOG_ERROR("Task %s handler is not initialized", qos_map_type_name.c_str()); @@ -1266,7 +1266,7 @@ void QosOrch::doTask(Consumer &consumer) it = consumer.m_toSync.erase(it); return; case task_process_status::task_need_retry : - SWSS_LOG_ERROR("Failed to process QOS task, retry it"); + SWSS_LOG_INFO("Failed to process QOS task, retry it"); it++; break; default: